Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Static Public Member Functions | List of all members
Nektar::FullMatrixFuncs Struct Reference

#include <MatrixFuncs.h>

Static Public Member Functions

static unsigned int GetRequiredStorageSize (unsigned int rows, unsigned int columns)
 
static unsigned int CalculateIndex (unsigned int totalRows, unsigned int totalColumns, unsigned int curRow, unsigned int curColumn)
 
static boost::tuples::tuple
< unsigned int, unsigned int > 
Advance (const unsigned int totalRows, const unsigned int totalColumns, const unsigned int curRow, const unsigned int curColumn)
 
template<typename DataType >
static void Invert (unsigned int rows, unsigned int columns, Array< OneD, DataType > &data, const char transpose)
 
static void EigenSolve (unsigned int n, const Array< OneD, const double > &A, Array< OneD, NekDouble > &EigValReal, Array< OneD, NekDouble > &EigValImag, Array< OneD, NekDouble > &EigVecs=NullNekDouble1DArray)
 

Detailed Description

Definition at line 74 of file MatrixFuncs.h.

Member Function Documentation

boost::tuples::tuple< unsigned int, unsigned int > Nektar::FullMatrixFuncs::Advance ( const unsigned int  totalRows,
const unsigned int  totalColumns,
const unsigned int  curRow,
const unsigned int  curColumn 
)
static

Definition at line 133 of file MatrixFuncs.cpp.

Referenced by Nektar::NekMatrix< DataType, StandardMatrixTag >::Advance().

135  {
136  unsigned int nextRow = curRow;
137  unsigned int nextColumn = curColumn;
138 
139  if( nextRow < totalRows )
140  {
141  ++nextRow;
142  }
143 
144  if( nextRow >= totalRows )
145  {
146  nextRow = 0;
147  ++nextColumn;
148  }
149 
150  if( nextColumn >= totalColumns )
151  {
152  nextRow = std::numeric_limits<unsigned int>::max();
153  nextColumn = std::numeric_limits<unsigned int>::max();
154  }
155 
156  return boost::tuples::tuple<unsigned int, unsigned int>(nextRow, nextColumn);
157  }
unsigned int Nektar::FullMatrixFuncs::CalculateIndex ( unsigned int  totalRows,
unsigned int  totalColumns,
unsigned int  curRow,
unsigned int  curColumn 
)
static

Definition at line 126 of file MatrixFuncs.cpp.

Referenced by Nektar::ConstMatrix< DataType >::CalculateIndex().

127  {
128  return curColumn*totalRows + curRow;
129  }
static void Nektar::FullMatrixFuncs::EigenSolve ( unsigned int  n,
const Array< OneD, const double > &  A,
Array< OneD, NekDouble > &  EigValReal,
Array< OneD, NekDouble > &  EigValImag,
Array< OneD, NekDouble > &  EigVecs = NullNekDouble1DArray 
)
inlinestatic

Definition at line 133 of file MatrixFuncs.h.

References ASSERTL0, and Nektar::NullNekDouble1DArray.

Referenced by Nektar::NekMatrix< DataType, StandardMatrixTag >::EigenSolve().

138  {
139  int lda = n,info = 0;
140  NekDouble dum;
141  char uplo = 'N';
142 
143  if(EigVecs != NullNekDouble1DArray) // calculate Right Eigen Vectors
144  {
145  int lwork = 4*lda;
146  Array<OneD,NekDouble> work(4*lda);
147  char lrev = 'V';
148  Lapack::Dgeev(uplo,lrev,lda, A.get(),lda,
149  EigValReal.get(),
150  EigValImag.get(),
151  &dum,1,
152  EigVecs.get(),lda,
153  &work[0],lwork,info);
154  }
155  else
156  {
157  int lwork = 3*lda;
158  Array<OneD,NekDouble> work(3*lda);
159  char lrev = 'N';
160  Lapack::Dgeev(uplo,lrev,lda,
161  A.get(),lda,
162  EigValReal.get(),
163  EigValImag.get(),
164  &dum,1,&dum,1,
165  &work[0],lwork,info);
166  }
167  ASSERTL0(info == 0,"Info is not zero");
168 
169  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
static Array< OneD, NekDouble > NullNekDouble1DArray
double NekDouble
unsigned int Nektar::FullMatrixFuncs::GetRequiredStorageSize ( unsigned int  rows,
unsigned int  columns 
)
static

Definition at line 121 of file MatrixFuncs.cpp.

Referenced by Nektar::ConstMatrix< DataType >::GetRequiredStorageSize().

122  {
123  return rows*columns;
124  }
template<typename DataType >
static void Nektar::FullMatrixFuncs::Invert ( unsigned int  rows,
unsigned int  columns,
Array< OneD, DataType > &  data,
const char  transpose 
)
inlinestatic

Definition at line 86 of file MatrixFuncs.h.

References ASSERTL0, and Nektar::Array< OneD, DataType >::get().

Referenced by Nektar::NekMatrix< DataType, StandardMatrixTag >::Invert().

89  {
90 #ifdef NEKTAR_USING_BLAS
91  ASSERTL0(rows==columns, "Only square matrices can be inverted.");
92  ASSERTL0(transpose=='N', "Only untransposed matrices may be inverted.");
93 
94  int m = rows;
95  int n = columns;
96  int info = 0;
97  Array<OneD, int> ipivot(n);
98  Array<OneD, DataType> work(n);
99 
100  Lapack::Dgetrf(m, n, data.get(), m, ipivot.get(), info);
101 
102  if( info < 0 )
103  {
104  std::string message = "ERROR: The " + boost::lexical_cast<std::string>(-info) + "th parameter had an illegal parameter for dgetrf";
105  ASSERTL0(false, message.c_str());
106  }
107  else if( info > 0 )
108  {
109  std::string message = "ERROR: Element u_" + boost::lexical_cast<std::string>(info) + boost::lexical_cast<std::string>(info) + " is 0 from dgetrf";
110  ASSERTL0(false, message.c_str());
111  }
112 
113  Lapack::Dgetri(n, data.get(), n, ipivot.get(),
114  work.get(), n, info);
115 
116  if( info < 0 )
117  {
118  std::string message = "ERROR: The " + boost::lexical_cast<std::string>(-info) + "th parameter had an illegal parameter for dgetri";
119  ASSERTL0(false, message.c_str());
120  }
121  else if( info > 0 )
122  {
123  std::string message = "ERROR: Element u_" + boost::lexical_cast<std::string>(info) + boost::lexical_cast<std::string>(info) + " is 0 from dgetri";
124  ASSERTL0(false, message.c_str());
125  }
126 
127  #else
128  // error Full matrix inversion not supported without blas.
129  BOOST_STATIC_ASSERT(sizeof(DataType) == 0);
130  #endif
131  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198