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

« back to all changes in this revision

Viewing changes to dolfin/la/MTL4Vector.h

  • 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
// Copyright (C) 2008 Dag Lindbo
 
2
// Licensed under the GNU LGPL Version 2.1.
 
3
//
 
4
// Modified by Anders Logg, 2008.
 
5
//
 
6
// First added:  2008-07-06
 
7
// Last changed: 2008-08-25
 
8
 
 
9
#ifdef HAS_MTL4
 
10
 
 
11
#ifndef __MTL4_VECTOR_H
 
12
#define __MTL4_VECTOR_H
 
13
 
 
14
#include <dolfin/log/LogStream.h>
 
15
#include <dolfin/common/Variable.h>
 
16
#include "mtl4.h"
 
17
#include "GenericVector.h"
 
18
 
 
19
/*
 
20
  Developers note:
 
21
  
 
22
  This class implements a minimal backend for MTL4.
 
23
 
 
24
  There are certain inline decisions that have been deferred.
 
25
  Due to the extensive calling of this backend through the generic LA
 
26
  interface, it is not clear where inlining will be possible and 
 
27
  improve performance.
 
28
*/
 
29
 
 
30
namespace dolfin
 
31
{
 
32
 
 
33
  class MTL4Vector: public GenericVector, public Variable
 
34
  {
 
35
  public:
 
36
 
 
37
    /// Create empty vector
 
38
    MTL4Vector();
 
39
 
 
40
    /// Create vector of size N
 
41
    explicit MTL4Vector(uint N);
 
42
 
 
43
    /// Copy constructor
 
44
    explicit MTL4Vector(const MTL4Vector& x);
 
45
 
 
46
    /// Destructor
 
47
    virtual ~MTL4Vector();
 
48
 
 
49
    //--- Implementation of the GenericTensor interface ---
 
50
 
 
51
    /// Return copy of tensor
 
52
    virtual MTL4Vector* copy() const;
 
53
 
 
54
    /// Set all entries to zero and keep any sparse structure
 
55
    virtual void zero();
 
56
 
 
57
    /// Finalize assembly of tensor
 
58
    virtual void apply();
 
59
 
 
60
    /// Display vector
 
61
    virtual void disp(uint precision=2) const;
 
62
 
 
63
    //--- Implementation of the GenericVector interface ---
 
64
 
 
65
    /// Resize vector to size N
 
66
    virtual void resize(uint N);
 
67
 
 
68
    /// Return size of vector
 
69
    virtual uint size() const;
 
70
 
 
71
    /// Get block of values
 
72
    virtual void get(double* block, uint m, const uint* rows) const;
 
73
 
 
74
    /// Set block of values
 
75
    virtual void set(const double* block, uint m, const uint* rows);
 
76
 
 
77
    /// Add block of values
 
78
    virtual void add(const double* block, uint m, const uint* rows);
 
79
 
 
80
    /// Get all values
 
81
    virtual void get(double* values) const;
 
82
 
 
83
    /// Set all values
 
84
    virtual void set(double* values);
 
85
 
 
86
    /// Add all values to each entry
 
87
    virtual void add(double* values);
 
88
 
 
89
    /// Add multiple of given vector (AXPY operation)
 
90
    virtual void axpy(double a, const GenericVector& x);
 
91
 
 
92
    /// Return inner product with given vector
 
93
    virtual double inner(const GenericVector& vector) const;
 
94
 
 
95
    /// Return norm of vector
 
96
    virtual double norm(dolfin::NormType type=l2) const;
 
97
 
 
98
    /// Return minimum value of vector
 
99
    virtual double min() const;
 
100
 
 
101
    /// Return maximum value of vector
 
102
    virtual double max() const;
 
103
 
 
104
    /// Multiply vector by given number
 
105
    virtual const MTL4Vector& operator*= (double a);
 
106
 
 
107
    /// Divide vector by given number
 
108
    virtual const MTL4Vector& operator/= (double a);
 
109
 
 
110
    /// Assignment operator
 
111
    virtual const MTL4Vector& operator= (double a);
 
112
 
 
113
    /// Add given vector
 
114
    virtual const MTL4Vector& operator+= (const GenericVector& x);
 
115
 
 
116
    /// Subtract given vector
 
117
    virtual const MTL4Vector& operator-= (const GenericVector& x);
 
118
 
 
119
    /// Assignment operator
 
120
    virtual const MTL4Vector& operator= (const GenericVector& x);
 
121
 
 
122
    /// Return pointer to underlying data (const version)
 
123
    virtual const double* data() const
 
124
    { return x.address_data(); }
 
125
 
 
126
    /// Return pointer to underlying data (non-const version)
 
127
    virtual double* data()
 
128
    { return x.address_data(); }
 
129
 
 
130
    //--- Special functions ---
 
131
    virtual LinearAlgebraFactory& factory() const;
 
132
 
 
133
    //--- Special MTL4 functions ---
 
134
 
 
135
    /// Return const mtl4_vector reference
 
136
    const mtl4_vector& vec() const;
 
137
    
 
138
    /// Return mtl4_vector reference
 
139
    mtl4_vector& vec();
 
140
 
 
141
    /// Assignment operator
 
142
    const MTL4Vector& operator= (const MTL4Vector& x);
 
143
 
 
144
    //friend class MTL4Matrix;
 
145
 
 
146
  private:
 
147
 
 
148
    // MTL4 vector object
 
149
    mtl4_vector x;
 
150
 
 
151
  };  
 
152
 
 
153
  LogStream& operator<< (LogStream& stream, const MTL4Vector& A);
 
154
 
 
155
}
 
156
 
 
157
#endif 
 
158
#endif