CppNoddy  0.92
Loading...
Searching...
No Matches
Public Member Functions | List of all members
CppNoddy::FortranData Class Reference

A little (legacy) utility class for passing CppNoddy containers to Fortran library routines. More...

#include <FortranData.h>

Inheritance diagram for CppNoddy::FortranData:
CppNoddy::Uncopyable

Public Member Functions

 FortranData (std::size_t size)
 Make an empty FortranData object that is not constructed from a CppNoddy container. More...
 
 FortranData (DenseMatrix< double > &matrix, bool transpose=true, int padding=0)
 Make a FortranData object from a double dense matrix (with potential) for padding the data to avoid cache contention. More...
 
 FortranData (DenseMatrix< D_complex > &matrix, bool transpose=true, int padding=0)
 Make a FortranData object from a complex dense matrix (with potential) for padding the data to avoid cache contention. More...
 
 FortranData (BandedMatrix< double > &matrix, bool transpose=true)
 
 FortranData (BandedMatrix< D_complex > &matrix, bool transpose=true)
 
 FortranData (DenseVector< D_complex > &vector)
 
 ~FortranData ()
 
double * base ()
 Get the pointer to the first element. More...
 
double & operator[] (const std::size_t &i)
 Get the reference to the first element. More...
 
std::size_t size () const
 Find the number of stored elements. More...
 
DenseMatrix< double > to_dense_matrix (std::size_t rows, std::size_t cols)
 Convert the data to a double dense format. More...
 
void dump ()
 Dump the data to standard out. More...
 

Detailed Description

A little (legacy) utility class for passing CppNoddy containers to Fortran library routines.

Definition at line 13 of file FortranData.h.

Constructor & Destructor Documentation

◆ FortranData() [1/6]

CppNoddy::FortranData::FortranData ( std::size_t  size)
inlineexplicit

Make an empty FortranData object that is not constructed from a CppNoddy container.

Definition at line 19 of file FortranData.h.

19 {
20 p_DATA = new DenseVector<double>(size, 0.0);
21 }
std::size_t size() const
Find the number of stored elements.
Definition: FortranData.h:92

References size().

◆ FortranData() [2/6]

CppNoddy::FortranData::FortranData ( DenseMatrix< double > &  matrix,
bool  transpose = true,
int  padding = 0 
)
inline

Make a FortranData object from a double dense matrix (with potential) for padding the data to avoid cache contention.

The transpose flag defaults to true in order to return data in column-major format.

Parameters
matrixA double dense matrix to convert to Lapack/Fortran format
transposeTranspose the matrix to be in column major format
paddingThe number of additional elements to pad the matrix

Definition at line 29 of file FortranData.h.

29 {
30 p_DATA = new DenseVector<double>;
31 if(transpose) {
32 matrix.transpose();
33 }
34 matrix.matrix_to_vector(*p_DATA, padding);
35 }
DenseVector< double > matrix_to_vector(const std::size_t &padding=0) const
Conversion to contiguous data in row major format Inefficient ... the void method is preferred.
void transpose()
Transpose the matrix.

References CppNoddy::DenseMatrix< _Type >::matrix_to_vector(), and CppNoddy::DenseMatrix< _Type >::transpose().

◆ FortranData() [3/6]

CppNoddy::FortranData::FortranData ( DenseMatrix< D_complex > &  matrix,
bool  transpose = true,
int  padding = 0 
)
inline

Make a FortranData object from a complex dense matrix (with potential) for padding the data to avoid cache contention.

The transpose flag defaults to true in order to return data in column-major format.

Parameters
matrixA complex dense matrix to convert to Lapack/Fortran format
transposeTranspose the matrix to be in column major format
paddingThe number of additional elements to pad the matrix

Definition at line 43 of file FortranData.h.

43 {
44 p_DATA = new DenseVector<double>;
45 if(transpose) {
46 matrix.transpose();
47 }
48 matrix.matrix_to_vector(*p_DATA, padding);
49 }

References CppNoddy::DenseMatrix< _Type >::matrix_to_vector(), and CppNoddy::DenseMatrix< _Type >::transpose().

◆ FortranData() [4/6]

CppNoddy::FortranData::FortranData ( BandedMatrix< double > &  matrix,
bool  transpose = true 
)
inline

Definition at line 51 of file FortranData.h.

51 {
52 std::string problem;
53 problem = "The default storage format for a banded matrix is now\n";
54 problem += "a contiguous column-major vector. You should not need to \n";
55 problem += "the FortranData method anymore.\n";
56 throw ExceptionRuntime(problem);
57 }

◆ FortranData() [5/6]

CppNoddy::FortranData::FortranData ( BandedMatrix< D_complex > &  matrix,
bool  transpose = true 
)
inline

Definition at line 59 of file FortranData.h.

59 {
60 std::string problem;
61 problem = "The default storage format for a banded matrix is now\n";
62 problem += "a contiguous column-major vector. You should not need to \n";
63 problem += "the FortranData method anymore.\n";
64 throw ExceptionRuntime(problem);
65 }

◆ FortranData() [6/6]

CppNoddy::FortranData::FortranData ( DenseVector< D_complex > &  vector)
inline

Definition at line 67 of file FortranData.h.

67 {
68 std::string problem;
69 problem = "This method is not required. Just use the base address of \n";
70 problem += "the first element and treat it as a vector of doubles.\n";
71 throw ExceptionRuntime(problem);
72 }

◆ ~FortranData()

CppNoddy::FortranData::~FortranData ( )
inline

Definition at line 74 of file FortranData.h.

74 {
75 delete p_DATA;
76 }

Member Function Documentation

◆ base()

double * CppNoddy::FortranData::base ( )
inline

Get the pointer to the first element.

Returns
The pointer to the base address.

Definition at line 80 of file FortranData.h.

80 {
81 return & (p_DATA -> operator[](0));
82 }
double & operator[](const std::size_t &i)
Get the reference to the first element.
Definition: FortranData.h:86

References operator[]().

Referenced by CppNoddy::Utility::multiply().

◆ dump()

void CppNoddy::FortranData::dump ( )
inline

Dump the data to standard out.

Definition at line 106 of file FortranData.h.

106 {
107 p_DATA -> dump();
108 }
void dump()
Dump the data to standard out.
Definition: FortranData.h:106

References dump().

Referenced by dump().

◆ operator[]()

double & CppNoddy::FortranData::operator[] ( const std::size_t &  i)
inline

Get the reference to the first element.

Returns
The the i-th element in the vector

Definition at line 86 of file FortranData.h.

86 {
87 return p_DATA -> operator[](i);
88 }

References operator[]().

Referenced by base(), and operator[]().

◆ size()

std::size_t CppNoddy::FortranData::size ( ) const
inline

Find the number of stored elements.

Returns
The number of elements.

Definition at line 92 of file FortranData.h.

92 {
93 return p_DATA -> size();
94 }

References size().

Referenced by FortranData(), and size().

◆ to_dense_matrix()

DenseMatrix< double > CppNoddy::FortranData::to_dense_matrix ( std::size_t  rows,
std::size_t  cols 
)
inline

Convert the data to a double dense format.

Parameters
rowsThe number of required rows
colsThe number of required columns
Returns
The DenseMatrix<double> of the data

Definition at line 100 of file FortranData.h.

100 {
101 DenseMatrix<double> matrix(rows, cols, &(p_DATA->operator[](0)));
102 return matrix;
103 }

Referenced by CppNoddy::Utility::multiply().


The documentation for this class was generated from the following file:

© 2012

R.E. Hewitt