1
// Copyright (C) 2008 Dag Lindbo
2
// Licensed under the GNU LGPL Version 2.1.
4
// Modified by Anders Logg, 2008.
6
// First added: 2008-07-06
7
// Last changed: 2008-08-25
11
#ifndef __MTL4_VECTOR_H
12
#define __MTL4_VECTOR_H
14
#include <dolfin/log/LogStream.h>
15
#include <dolfin/common/Variable.h>
17
#include "GenericVector.h"
22
This class implements a minimal backend for MTL4.
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
33
class MTL4Vector: public GenericVector, public Variable
37
/// Create empty vector
40
/// Create vector of size N
41
explicit MTL4Vector(uint N);
44
explicit MTL4Vector(const MTL4Vector& x);
47
virtual ~MTL4Vector();
49
//--- Implementation of the GenericTensor interface ---
51
/// Return copy of tensor
52
virtual MTL4Vector* copy() const;
54
/// Set all entries to zero and keep any sparse structure
57
/// Finalize assembly of tensor
61
virtual void disp(uint precision=2) const;
63
//--- Implementation of the GenericVector interface ---
65
/// Resize vector to size N
66
virtual void resize(uint N);
68
/// Return size of vector
69
virtual uint size() const;
71
/// Get block of values
72
virtual void get(double* block, uint m, const uint* rows) const;
74
/// Set block of values
75
virtual void set(const double* block, uint m, const uint* rows);
77
/// Add block of values
78
virtual void add(const double* block, uint m, const uint* rows);
81
virtual void get(double* values) const;
84
virtual void set(double* values);
86
/// Add all values to each entry
87
virtual void add(double* values);
89
/// Add multiple of given vector (AXPY operation)
90
virtual void axpy(double a, const GenericVector& x);
92
/// Return inner product with given vector
93
virtual double inner(const GenericVector& vector) const;
95
/// Return norm of vector
96
virtual double norm(dolfin::NormType type=l2) const;
98
/// Return minimum value of vector
99
virtual double min() const;
101
/// Return maximum value of vector
102
virtual double max() const;
104
/// Multiply vector by given number
105
virtual const MTL4Vector& operator*= (double a);
107
/// Divide vector by given number
108
virtual const MTL4Vector& operator/= (double a);
110
/// Assignment operator
111
virtual const MTL4Vector& operator= (double a);
114
virtual const MTL4Vector& operator+= (const GenericVector& x);
116
/// Subtract given vector
117
virtual const MTL4Vector& operator-= (const GenericVector& x);
119
/// Assignment operator
120
virtual const MTL4Vector& operator= (const GenericVector& x);
122
/// Return pointer to underlying data (const version)
123
virtual const double* data() const
124
{ return x.address_data(); }
126
/// Return pointer to underlying data (non-const version)
127
virtual double* data()
128
{ return x.address_data(); }
130
//--- Special functions ---
131
virtual LinearAlgebraFactory& factory() const;
133
//--- Special MTL4 functions ---
135
/// Return const mtl4_vector reference
136
const mtl4_vector& vec() const;
138
/// Return mtl4_vector reference
141
/// Assignment operator
142
const MTL4Vector& operator= (const MTL4Vector& x);
144
//friend class MTL4Matrix;
148
// MTL4 vector object
153
LogStream& operator<< (LogStream& stream, const MTL4Vector& A);