~njansson/dolfin/hpc

« back to all changes in this revision

Viewing changes to dolfin/la/uBlasFactory.h

  • Committer: Garth N. Wells
  • Date: 2008-05-18 16:18:26 UTC
  • mfrom: (2668.2.1 trunk)
  • mto: (2668.7.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 2670.
  • Revision ID: gnw20@cam.ac.uk-20080518161826-rb28aps5hkd304zh
merge.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// Copyright (C) 2007 Ola Skavhaug.
2
2
// Licensed under the GNU LGPL Version 2.1.
3
3
//
 
4
// Modified by Garth N. Wells, 2008.
 
5
//
4
6
// First added:  2007-12-06
5
 
// Last changed: 2007-12-06
 
7
// Last changed: 2008-05-18
6
8
 
7
9
#ifndef __UBLAS_FACTORY_H
8
10
#define __UBLAS_FACTORY_H
12
14
#include "SparsityPattern.h"
13
15
#include "LinearAlgebraFactory.h"
14
16
 
 
17
 
15
18
namespace dolfin
16
19
{
 
20
  // Forward declaration
 
21
  template< class T> class uBlasMatrix;
17
22
 
 
23
  template<class Mat = ublas_sparse_matrix>
18
24
  class uBlasFactory: public LinearAlgebraFactory
19
25
  {
20
26
  public:
23
29
    virtual ~uBlasFactory() {}
24
30
 
25
31
    /// Create empty matrix
26
 
    uBlasMatrix<ublas_sparse_matrix>* createMatrix() const;
 
32
    uBlasMatrix<Mat>* createMatrix() const
 
33
    { return new uBlasMatrix<Mat>(); }
 
34
 
 
35
    /// Create empty sparsity pattern 
 
36
    SparsityPattern* createPattern() const
 
37
    { return new SparsityPattern(); }
27
38
 
28
39
    /// Create empty vector
29
 
    uBlasVector* createVector() const;
30
 
 
31
 
    /// Create empty sparsity pattern 
32
 
    SparsityPattern* createPattern() const;
33
 
 
34
 
    /// Return sigleton instance
35
 
    static uBlasFactory& instance()
 
40
    uBlasVector* createVector() const
 
41
    { return new uBlasVector(); }
 
42
 
 
43
    static uBlasFactory<Mat>& instance() 
36
44
    { return factory; }
37
45
 
38
46
  private:
 
47
 
39
48
    /// Private Constructor
40
49
    uBlasFactory() {}
41
50
 
42
 
    static uBlasFactory factory;
43
 
 
 
51
    static uBlasFactory<Mat> factory;
44
52
  };
45
 
 
46
53
}
47
54
 
 
55
// Initialise static data
 
56
template<class Mat> dolfin::uBlasFactory<Mat> dolfin::uBlasFactory<Mat>::factory;
 
57
 
 
58
 
48
59
#endif