source: trunk/test/matrix_test.cc @ 393

Last change on this file since 393 was 393, checked in by Peter, 18 years ago

extended test of matrix

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 815 bytes
Line 
1// $Id: matrix_test.cc 393 2005-09-14 18:25:03Z peter $
2
3#include <c++_tools/gslapi/matrix.h>
4
5#include <fstream>
6#include <iostream>
7
8int main(const int argc,const char* argv[])
9{ 
10  using namespace theplu;
11  std::ostream* error;
12  if (argc>1 && argv[1]==std::string("-p"))
13    error = &std::cerr;
14  else 
15    error = new std::ofstream("/dev/null");
16
17  *error << "testing matrix" << std::endl;
18
19  bool ok = true;
20
21  gslapi::matrix m(3,3,9);
22
23  gslapi::matrix m2(m);
24  if (m2!=m)
25    ok=false;
26  std::ofstream my_out("data/tmp_test_matrix.txt");
27  my_out << m2;
28  my_out.close();
29
30  std::ifstream is("data/tmp_test_matrix.txt");
31  gslapi::matrix m3(is);
32  is.close();
33  if (m3!=m2)
34    ok=false;
35
36  gslapi::matrix m4(3,3,1);
37  m4 *= 9;
38 
39  if (m4!=m){
40    ok=false;
41    *error << "error operator*=(double)" << std::endl;
42  }
43
44
45  if (error!=&std::cerr)
46    delete error;
47
48  return (ok ? 0 : -1);
49
50}
Note: See TracBrowser for help on using the repository browser.