<commit_before>//--------------------------------------------------------------------
//    $Id$
//    Version: $Name$ 
//
//    Copyright (C) 2005 by the deal.II authors
//
//    This file is subject to QPL and may not be  distributed
//    without copyright and license information. Please refer
//    to the file deal.II/doc/license.html for the  text  and
//    further information on this license.
//
//--------------------------------------------------------------------

// Tests all aspects of LAPACKFullMatrix

#include "../tests.h"
#include <base/logstream.h>
#include <lac/lapack_full_matrix.h>
#include <lac/full_matrix.h>
#include <lac/vector.h>

#include <fstream>
#include <iostream>

const double symm[] =
{
      4., 1., -1., 1.,
      1., 4., 1., -1.,
      -1., 1., 4., 1.,
      1., -1., 4., 1.
};

const double rect[] =
{
      4., 3., 2., 1.,
      5., 8., 1., -2.,
      11., 13., -4., -5
};


int main()
{
  std::ofstream logfile("lapack.output");
  logfile.precision(4);
  deallog.attach(logfile);
  deallog.depth_console(0);

#ifdef HAVE_LIBLAPACK
  FullMatrix<double> A(3,4,rect);
  LAPACKFullMatrix<double> LA(3,4);
  LA = A;
  
  Vector<double> u(4);
  Vector<double> v1(3);
  Vector<double> v2(3);
  
  for (unsigned int i=0;i<u.size();++i)
    u(i) = i*i;
  
				   // Test rectangular vmult. All
				   // results compare with same
				   // operation for FullMatrix.
  deallog.push("Rect");
  
  A.vmult(v1,u);
  LA.vmult(v2,u);
  v1 -= v2;
  if (v1.l2_norm() < 1.e-14)
    deallog << "vmult ok" << std::endl;
  v1 = v2;
  
  A.vmult_add(v1,u);
  LA.vmult_add(v2,u);
  v1 -= v2;
  if (v1.l2_norm() < 1.e-14)
    deallog << "vmult_add ok" << std::endl;
  
  LA.Tvmult(u, v2);
  u *= -1;
  A.Tvmult_add(u, v2);
  if (u.l2_norm() < 1.e-14)
    deallog << "Tvmult ok" << std::endl;
  
  A.Tvmult(u, v2);
  u *= -1;
  LA.Tvmult_add(u, v2);
  if (u.l2_norm() < 1.e-14)
    deallog << "Tvmult_add ok" << std::endl;
  
  deallog.pop();

				   // Test symmetric system
  A.reinit(4,4);
  LA.reinit(4,4);
  A.fill(symm);
  LA = A;
  v1.reinit(4);
  v2.reinit(4);
  
#else
  deallog.push("Rect");
  deallog << "vmult ok" << std::endl;
  deallog << "vmult_add ok" << std::endl;
  deallog << "Tvmult ok" << std::endl;
  deallog << "Tvmult_add ok" << std::endl;
  deallog.pop();
#endif
}<commit_msg>additional output<commit_after>//--------------------------------------------------------------------
//    $Id$
//    Version: $Name$ 
//
//    Copyright (C) 2005 by the deal.II authors
//
//    This file is subject to QPL and may not be  distributed
//    without copyright and license information. Please refer
//    to the file deal.II/doc/license.html for the  text  and
//    further information on this license.
//
//--------------------------------------------------------------------

// Tests all aspects of LAPACKFullMatrix

#include "../tests.h"
#include <base/logstream.h>
#include <lac/lapack_full_matrix.h>
#include <lac/full_matrix.h>
#include <lac/vector.h>

#include <fstream>
#include <iostream>

const double symm[] =
{
      4., 1., -1., 1.,
      1., 4., 1., -1.,
      -1., 1., 4., 1.,
      1., -1., 4., 1.
};

const double rect[] =
{
      4., 3., 2., 1.,
      5., 8., 1., -2.,
      11., 13., -4., -5
};


int main()
{
  std::ofstream logfile("lapack.output");
  logfile.precision(4);
  deallog.attach(logfile);
  deallog.depth_console(0);

#ifdef HAVE_LIBLAPACK
  FullMatrix<double> A(3,4,rect);
  LAPACKFullMatrix<double> LA(3,4);
  LA = A;
  
  Vector<double> u(4);
  Vector<double> v1(3);
  Vector<double> v2(3);
  
  for (unsigned int i=0;i<u.size();++i)
    u(i) = i*i;
  
				   // Test rectangular vmult. All
				   // results compare with same
				   // operation for FullMatrix.
  deallog.push("Rect");

  deallog << "operator= (const FullMatrix<number>&) ok" << std::endl;
  
  A.vmult(v1,u);
  LA.vmult(v2,u);
  v1 -= v2;
  if (v1.l2_norm() < 1.e-14)
    deallog << "vmult ok" << std::endl;
  v1 = v2;
  
  A.vmult_add(v1,u);
  LA.vmult_add(v2,u);
  v1 -= v2;
  if (v1.l2_norm() < 1.e-14)
    deallog << "vmult_add ok" << std::endl;
  
  LA.Tvmult(u, v2);
  u *= -1;
  A.Tvmult_add(u, v2);
  if (u.l2_norm() < 1.e-14)
    deallog << "Tvmult ok" << std::endl;
  
  A.Tvmult(u, v2);
  u *= -1;
  LA.Tvmult_add(u, v2);
  if (u.l2_norm() < 1.e-14)
    deallog << "Tvmult_add ok" << std::endl;
  
  deallog.pop();

				   // Test symmetric system
  A.reinit(4,4);
  LA.reinit(4,4);
  A.fill(symm);
  LA = A;
  v1.reinit(4);
  v2.reinit(4);
  
#else
				   // If lapack is not available, this
				   // test will not complain.
  deallog.push("Rect");
  deallog << "operator= (const FullMatrix<number>&) ok" << std::endl;
  deallog << "vmult ok" << std::endl;
  deallog << "vmult_add ok" << std::endl;
  deallog << "Tvmult ok" << std::endl;
  deallog << "Tvmult_add ok" << std::endl;
  deallog.pop();
#endif
}
{'fraction_non_alphanumeric': 0.24238683127572017, 'fraction_numerical': 0.03621399176954732, 'mean_word_length': 2.072692793931732, 'pattern_counts': {'":': 0, '<': 109, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5069164', 'n_tokens_mistral': 2101, 'n_tokens_neox': 1981, 'n_words': 453}