12 #ifndef MFEM_SYMMETRICMAT 13 #define MFEM_SYMMETRICMAT 15 #include "../config/config.hpp" 16 #include "../general/globals.hpp" 50 data.
Wrap(d, (
s*(
s+1))/2,
false);
76 inline double *
Data()
const 77 {
return const_cast<double*
>((
const double*)data);}
92 inline const double &
operator()(
int i,
int j)
const;
95 virtual double &
Elem(
int i,
int j);
98 virtual const double &
Elem(
int i,
int j)
const;
108 const double *
Read(
bool on_dev =
true)
const 152 MFEM_ASSERT(data && i >= 0 && i < height && j >= 0 && j <
width,
"");
155 return data[(j*
height) - (((j-1)*j)/2) + i - j];
159 return data[(i*
height) - (((i-1)*i)/2) + j - i];
165 MFEM_ASSERT(data && i >= 0 && i < height && j >= 0 && j <
width,
"");
168 return data[(j*
height) - (((j-1)*j)/2) + i - j];
172 return data[(i*
height) - (((i-1)*i)/2) + j - i];
double & operator()(int i, int j)
Returns reference to a_{ij}.
double * Write(bool on_dev=true)
Shortcut for mfem::Write(GetMemory(), TotalSize(), on_dev).
void SetSize(int s)
Change the size of the DenseSymmetricMatrix to s x s.
void Delete()
Delete the owned pointers and reset the Memory object.
DenseSymmetricMatrix & operator*=(double c)
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
T * Write(Memory< T > &mem, int size, bool on_dev=true)
Get a pointer for write access to mem with the mfem::Device's DeviceMemoryClass, if on_dev = true...
Abstract data type for matrix inverse.
double * ReadWrite(bool on_dev=true)
Shortcut for mfem::ReadWrite(GetMemory(), TotalSize(), on_dev).
virtual double & Elem(int i, int j)
Returns reference to a_{ij}.
void Wrap(T *ptr, int size, bool own)
Wrap an externally allocated host pointer, ptr with the current host memory type returned by MemoryMa...
int GetStoredSize() const
Return the number of stored nonzeros in the matrix.
Abstract data type matrix.
DenseSymmetricMatrix(double *d, int s)
Construct a DenseSymmetricMatrix using an existing data array.
void UseExternalData(double *d, int s)
Change the data array and the size of the DenseSymmetricMatrix.
bool OwnsData() const
Return the DenseSymmetricMatrix data (host pointer) ownership flag.
double * GetData() const
Returns the matrix data array.
int Capacity() const
Return the size of the allocated memory.
const T * Read(const Memory< T > &mem, int size, bool on_dev=true)
Get a pointer for read access to mem with the mfem::Device's DeviceMemoryClass, if on_dev = true...
void Reset()
Reset the memory to be empty, ensuring that Delete() will be a no-op.
virtual void Print(std::ostream &out=mfem::out, int width_=4) const
Prints matrix to stream out.
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
int height
Dimension of the output / number of rows in the matrix.
const double * Read(bool on_dev=true) const
Shortcut for mfem::Read( GetMemory(), TotalSize(), on_dev).
virtual void Mult(const Vector &x, Vector &y) const
Matrix vector multiplication.
T * ReadWrite(Memory< T > &mem, int size, bool on_dev=true)
Get a pointer for read+write access to mem with the mfem::Device's DeviceMemoryClass, if on_dev = true, or the mfem::Device's HostMemoryClass, otherwise.
void Clear()
Delete the matrix data array (if owned) and reset the matrix state.
double * HostReadWrite()
Shortcut for mfem::ReadWrite(GetMemory(), TotalSize(), false).
virtual ~DenseSymmetricMatrix()
Destroys the symmetric matrix.
std::size_t MemoryUsage() const
const double * HostRead() const
Shortcut for mfem::Read(GetMemory(), TotalSize(), false).
bool OwnsHostPtr() const
Return true if the host pointer is owned. Ownership indicates whether the pointer will be deleted by ...
const Memory< double > & GetMemory() const
virtual MatrixInverse * Inverse() const
Returns a pointer to (an approximation) of the matrix inverse.
double * HostWrite()
Shortcut for mfem::Write(GetMemory(), TotalSize(), false).
DenseSymmetricMatrix & operator=(double c)
Sets the matrix elements equal to constant c.
double * Data() const
Returns the matrix data array.
Memory< double > & GetMemory()
int width
Dimension of the input / number of columns in the matrix.
void Reset(double *d, int s)
Change the data array and the size of the DenseSymmetricMatrix.