~ubuntu-branches/ubuntu/maverick/dolfin/maverick

« back to all changes in this revision

Viewing changes to sandbox/mtl4/op/vec.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Johannes Ring
  • Date: 2008-09-16 08:41:20 UTC
  • Revision ID: james.westby@ubuntu.com-20080916084120-i8k3u6lhx3mw3py3
Tags: upstream-0.9.2
ImportĀ upstreamĀ versionĀ 0.9.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "boost/tuple/tuple.hpp"
 
2
#include <dolfin.h>
 
3
#include "Poisson.h"
 
4
 
 
5
using namespace dolfin;
 
6
 
 
7
int main(int args, char* argv[])
 
8
{
 
9
 
 
10
  dolfin_set("linear algebra backend","MTL4");
 
11
 
 
12
  // Create mesh and forms
 
13
  UnitSquare mesh(2, 2);
 
14
  Function f(mesh,2.0);
 
15
  PoissonBilinearForm a;
 
16
  PoissonLinearForm L(f);
 
17
 
 
18
  Assembler assembler(mesh);
 
19
 
 
20
  MTL4Matrix A(9,9,5);
 
21
  assembler.assemble(A, a, false); 
 
22
 
 
23
  Vector x;
 
24
  assembler.assemble(x, L);
 
25
  x.disp();
 
26
 
 
27
  //Vector y(x);
 
28
  Vector y;
 
29
  y = x;
 
30
  y.disp();
 
31
 
 
32
  x.axpy(2,y);
 
33
  x.disp();
 
34
  y.disp();
 
35
 
 
36
  cout << x.size() << endl;
 
37
 
 
38
  double val[9];
 
39
  x.get(val);
 
40
 
 
41
  for(int i=0; i<9; i++) cout << val[i] << " ";
 
42
  cout << endl;
 
43
 
 
44
  val[2] = 43;
 
45
  x.set(val);
 
46
  x.disp();
 
47
 
 
48
  x.add(val);
 
49
  x.disp();
 
50
 
 
51
  double vval[2];
 
52
  dolfin::uint cols[2] = {0, 2};
 
53
  x.get(vval, 2, cols);
 
54
 
 
55
  for(int i=0; i<2; i++) cout << vval[i] << " ";
 
56
  cout << endl;
 
57
 
 
58
  double dot = x.inner(x);
 
59
  cout << dot << endl;
 
60
 
 
61
  y = 3.14;
 
62
  y.disp();
 
63
    
 
64
  y *= 2;
 
65
  y.disp();
 
66
 
 
67
  y /= 2;
 
68
  y.disp();
 
69
 
 
70
  y += x;
 
71
  y.disp();
 
72
  
 
73
  y -= x;
 
74
  y.disp();
 
75
 
 
76
  return 0;
 
77
}