12#ifndef MFEM_SYMMETRICMAT
13#define MFEM_SYMMETRICMAT
50 data.
Wrap(d, (
s*(
s+1))/2,
false);
98 virtual const real_t &
Elem(
int i,
int j)
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];
DenseSymmetricMatrix(real_t *d, int s)
Construct a DenseSymmetricMatrix using an existing data array.
const Memory< real_t > & GetMemory() const
virtual void Mult(const Vector &x, Vector &y) const
Matrix vector multiplication.
real_t * HostWrite()
Shortcut for mfem::Write(GetMemory(), TotalSize(), false).
virtual real_t & Elem(int i, int j)
Returns reference to a_{ij}.
void SetSize(int s)
Change the size of the DenseSymmetricMatrix to s x s.
const real_t * HostRead() const
Shortcut for mfem::Read(GetMemory(), TotalSize(), false).
void UseExternalData(real_t *d, int s)
Change the data array and the size of the DenseSymmetricMatrix.
real_t * ReadWrite(bool on_dev=true)
Shortcut for mfem::ReadWrite(GetMemory(), TotalSize(), on_dev).
virtual MatrixInverse * Inverse() const
Returns a pointer to (an approximation) of the matrix inverse.
DenseSymmetricMatrix & operator*=(real_t c)
int GetStoredSize() const
Return the number of stored nonzeros in the matrix.
real_t & operator()(int i, int j)
Returns reference to a_{ij}.
real_t * HostReadWrite()
Shortcut for mfem::ReadWrite(GetMemory(), TotalSize(), false).
std::size_t MemoryUsage() const
void Clear()
Delete the matrix data array (if owned) and reset the matrix state.
real_t * Data() const
Returns the matrix data array.
Memory< real_t > & GetMemory()
bool OwnsData() const
Return the DenseSymmetricMatrix data (host pointer) ownership flag.
real_t * Write(bool on_dev=true)
Shortcut for mfem::Write(GetMemory(), TotalSize(), on_dev).
const real_t * Read(bool on_dev=true) const
Shortcut for mfem::Read( GetMemory(), TotalSize(), on_dev).
real_t * GetData() const
Returns the matrix data array.
virtual ~DenseSymmetricMatrix()
Destroys the symmetric matrix.
DenseSymmetricMatrix & operator=(real_t c)
Sets the matrix elements equal to constant c.
virtual void Print(std::ostream &out=mfem::out, int width_=4) const
Prints matrix to stream out.
void Reset(real_t *d, int s)
Change the data array and the size of the DenseSymmetricMatrix.
Abstract data type for matrix inverse.
Abstract data type matrix.
Class used by MFEM to store pointers to host and/or device memory.
int Capacity() const
Return the size of the allocated memory.
bool OwnsHostPtr() const
Return true if the host pointer is owned. Ownership indicates whether the pointer will be deleted by ...
void Reset()
Reset the memory to be empty, ensuring that Delete() will be a no-op.
void Wrap(T *ptr, int size, bool own)
Wrap an externally allocated host pointer, ptr with the current host memory type returned by MemoryMa...
void Delete()
Delete the owned pointers and reset the Memory object.
int width
Dimension of the input / number of columns in the matrix.
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.
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
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,...
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,...
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
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,...