Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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().

{
unsigned int nextRow = curRow;
unsigned int nextColumn = curColumn;
if( nextRow < totalRows )
{
++nextRow;
}
if( nextRow >= totalRows )
{
nextRow = 0;
++nextColumn;
}
if( nextColumn >= totalColumns )
{
nextRow = std::numeric_limits<unsigned int>::max();
nextColumn = std::numeric_limits<unsigned int>::max();
}
return boost::tuples::tuple<unsigned int, unsigned int>(nextRow, nextColumn);
}
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().

{
return curColumn*totalRows + curRow;
}
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().

{
int lda = n,info = 0;
NekDouble dum;
int lwork = 3*lda;
Array<OneD,NekDouble> work(3*lda);
char uplo = 'N';
if(EigVecs != NullNekDouble1DArray) // calculate Right Eigen Vectors
{
char lrev = 'V';
Lapack::Dgeev(uplo,lrev,lda, A.get(),lda,
EigValReal.get(),
EigValImag.get(),
&dum,1,
EigVecs.get(),lda,
&work[0],lwork,info);
}
else
{
char lrev = 'N';
Lapack::Dgeev(uplo,lrev,lda,
A.get(),lda,
EigValReal.get(),
EigValImag.get(),
&dum,1,&dum,1,
&work[0],lwork,info);
}
ASSERTL0(info == 0,"Info is not zero");
}
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().

{
return rows*columns;
}
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().

{
#ifdef NEKTAR_USING_BLAS
ASSERTL0(rows==columns, "Only square matrices can be inverted.");
ASSERTL0(transpose=='N', "Only untransposed matrices may be inverted.");
int m = rows;
int n = columns;
int info = 0;
Array<OneD, int> ipivot(n);
Array<OneD, DataType> work(n);
Lapack::Dgetrf(m, n, data.get(), m, ipivot.get(), info);
if( info < 0 )
{
std::string message = "ERROR: The " + boost::lexical_cast<std::string>(-info) + "th parameter had an illegal parameter for dgetrf";
ASSERTL0(false, message.c_str());
}
else if( info > 0 )
{
std::string message = "ERROR: Element u_" + boost::lexical_cast<std::string>(info) + boost::lexical_cast<std::string>(info) + " is 0 from dgetrf";
ASSERTL0(false, message.c_str());
}
Lapack::Dgetri(n, data.get(), n, ipivot.get(),
work.get(), n, info);
if( info < 0 )
{
std::string message = "ERROR: The " + boost::lexical_cast<std::string>(-info) + "th parameter had an illegal parameter for dgetri";
ASSERTL0(false, message.c_str());
}
else if( info > 0 )
{
std::string message = "ERROR: Element u_" + boost::lexical_cast<std::string>(info) + boost::lexical_cast<std::string>(info) + " is 0 from dgetri";
ASSERTL0(false, message.c_str());
}
#else
// error Full matrix inversion not supported without blas.
BOOST_STATIC_ASSERT(sizeof(DataType) == 0);
#endif
}