~njansson/dolfin/hpc

« back to all changes in this revision

Viewing changes to dolfin/la/uBlasFactory.h

  • Committer: Kent-Andre Mardal
  • Date: 2008-05-19 14:21:52 UTC
  • mfrom: (2668.5.1 trunk)
  • mto: (2668.1.16 trunk)
  • mto: This revision was merged to the branch mainline in revision 2670.
  • Revision ID: kent-and@simula.no-20080519142152-7zb7r4htl7111izh
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
6
 
 
 
7
// Last changed: 2008-05-18
7
8
 
8
9
#ifndef __UBLAS_FACTORY_H
9
10
#define __UBLAS_FACTORY_H
13
14
#include "SparsityPattern.h"
14
15
#include "LinearAlgebraFactory.h"
15
16
 
 
17
 
16
18
namespace dolfin
17
19
{
 
20
  // Forward declaration
 
21
  template< class T> class uBlasMatrix;
18
22
 
 
23
  template<class Mat = ublas_sparse_matrix>
19
24
  class uBlasFactory: public LinearAlgebraFactory
20
25
  {
21
26
  public:
24
29
    virtual ~uBlasFactory() {}
25
30
 
26
31
    /// Create empty matrix
27
 
    uBlasMatrix<ublas_sparse_matrix>* createMatrix() const;
 
32
    uBlasMatrix<Mat>* createMatrix() const
 
33
    { return new uBlasMatrix<Mat>(); }
28
34
 
29
35
    /// Create empty sparsity pattern 
30
 
    SparsityPattern* createPattern() const;
 
36
    SparsityPattern* createPattern() const
 
37
    { return new SparsityPattern(); }
31
38
 
32
39
    /// Create empty vector
33
 
    uBlasVector* createVector() const;
 
40
    uBlasVector* createVector() const
 
41
    { return new uBlasVector(); }
34
42
 
35
 
    /// Return sigleton instance
36
 
    static uBlasFactory& instance() { return ublasfactory; }
 
43
    static uBlasFactory<Mat>& instance() 
 
44
    { return factory; }
37
45
 
38
46
  private:
39
 
    /// Private Constructor
 
47
 
 
48
    // Private Constructor
40
49
    uBlasFactory() {}
41
50
 
42
 
    static uBlasFactory ublasfactory;
43
 
 
 
51
    // Singleton instance
 
52
    static uBlasFactory<Mat> factory;
44
53
  };
45
 
 
46
54
}
47
55
 
 
56
// Initialise static data
 
57
template<class Mat> dolfin::uBlasFactory<Mat> dolfin::uBlasFactory<Mat>::factory;
 
58
 
 
59
 
48
60
#endif