source: trunk/test/view_test.cc @ 1114

Last change on this file since 1114 was 1114, checked in by Peter, 15 years ago

adding test program for view provided from Markus.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1// $Id: view_test.cc 1114 2008-02-21 18:30:09Z peter $
2
3/*
4  Copyright (C) 2008 Peter Johansson, Markus Ringnér
5
6  This file is part of the yat library, http://trac.thep.lu.se/yat
7
8  The yat library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2 of the
11  License, or (at your option) any later version.
12
13  The yat library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21  02111-1307, USA.
22*/
23
24#include "yat/utility/matrix.h"
25#include "yat/utility/VectorBase.h"
26#include "yat/utility/VectorMutable.h"
27#include "yat/utility/VectorView.h"
28#include "yat/utility/VectorConstView.h"
29
30#include <iostream>
31#include <string>
32
33using namespace theplu::yat::utility;
34
35
36void f(const VectorBase& aa, VectorMutable& bb) {
37  std::cout << "f aa: " << aa << std::endl;
38  std::cout << "f bb: " << bb << std::endl;
39}
40
41int main(const int argc,const char* argv[])
42{ 
43
44  matrix data1;
45  data1.resize(3,1);
46  for(size_t i=0;i<3;i++) {
47    data1(i,0)=7+i;
48  }
49
50  matrix data2(3,1,1.0);
51
52  VectorConstView a=data1.column_const_view(0);
53  VectorView b=data2.column_view(0);
54
55  std::cout << "First\n";
56  f(a,b);
57
58  std::cout << "Second\n";
59  f(a,b);
60
61  std::cout << "Third\n";
62  f(data1.column_const_view(0),b);
63
64  std::cout << "Fourth\n";
65  f(a,b);
66
67  std::cout << "data 2:\n" << data2 << std::endl;
68}
69
70
Note: See TracBrowser for help on using the repository browser.