JDFTx  1.7.0
matrix Class Reference

General complex matrix. More...

#include <matrix.h>

Inheritance diagram for matrix:
ManagedMemory< complex > ManagedMemoryBase

Public Member Functions

int nRows () const
 
int nCols () const
 
int index (int i, int j) const
 Index into data()
 
 operator bool () const
 Test null-ness of matrix.
 
void init (int nrows, int ncols, bool onGpu=false)
 called by the constructors
 
void reshape (int nrows, int ncols)
 change the dimensions without altering the data (zero dimensions are filled in to match size)
 
 matrix (int nrows=0, int ncols=0, bool onGpu=false)
 
 matrix (const matrix &m1)
 copy constructor
 
 matrix (matrix &&m1)
 move constructor
 
 matrix (const diagMatrix &)
 convert from a real diagonal matrix
 
 matrix (const std::vector< complex > &)
 convert from a complex diagonal matrix
 
 matrix (const matrix3<> &)
 convert from a 3x3 matrix
 
matrixoperator= (const matrix &m1)
 copy-assignment
 
matrixoperator= (matrix &&m1)
 move-assignment
 
complex operator() (int i, int j) const
 get a specific element of the matrix
 
struct matrixScaledTransOp operator ()(int iStart
 get submatrix of elements (iStart <= i < iStop, jStart <= j < jStop)
 
matrix operator() (int iStart, int iStep, int iStop, int jStart, int jStep, int jStop) const
 get submatrix of elements (iStart <= i < iStop, jStart <= j < jStop) with arbitrary increments
 
void set (int i, int j, complex m)
 set element to m
 
void set (int iStart, int iStop, int jStart, int jStop, const matrix &m)
 set submatrix to m
 
void set (int iStart, int iStep, int iStop, int jStart, int jStep, int jStop, const matrix &m)
 set submatrix to m at arbitrary increments
 
void accum (int iStart, int iStop, int jStart, int jStop, const matrix &m)
 accumulate m on submatrix
 
void accum (int iStart, int iStep, int iStop, int jStart, int jStep, int jStop, const matrix &m)
 accumulate m on submatrix at arbitrary increments
 
void scan (FILE *fp, const char *fmt="%lg%+lgi")
 read (ascii) from stream
 
void scan_real (FILE *fp)
 read (ascii) real parts from stream, setting imaginary parts to 0
 
void print (FILE *fp, const char *fmt="%lg%+lgi\t") const
 print (ascii) to stream
 
void print_real (FILE *fp, const char *fmt="%lg\t") const
 print (ascii) real parts to stream
 
void diagonalize (matrix &evecs, diagMatrix &eigs) const
 diagonalize a hermitian matrix
 
void diagonalize (matrix &levecs, std::vector< complex > &eigs, matrix &revecs) const
 diagonalize an arbitrary matrix
 
void svd (matrix &U, diagMatrix &S, matrix &Vdag) const
 singular value decomposition (for dimensions of this: MxN, on output U: MxM, S: min(M,N), Vdag: NxN)
 
complex getElement (vector3< int > index, class GridInfo &gInfo)
 get element at grid coordinate from a Nx*Ny*Nzx1 matrix
 
matrix getLine (vector3< int > line, vector3< int > point, class GridInfo &gInfo)
 get a linear slice from a Nx*Ny*Nzx1 matrix
 
matrix getPlane (vector3< int > normal, vector3< int > point, class GridInfo &gInfo)
 get a planar slice from a Nx*Ny*Nzx1 matrix
 
- Public Member Functions inherited from ManagedMemory< complex >
complexdata ()
 Return a pointer to the actual data Return a CPU pointer to the actual data, will move data from GPU to CPU if necessary In GPU mode, care must be taken when calling this from multiple cpu threads Only the "GPU Owner" thread may call this when the data is actually on the GPU. Ideally call once from main thread to get data onto the cpu before launching other cpu threads.
 
const complexdata () const
 Return a const pointer to the actual data Return a CPU pointer to the actual data, will move data from GPU to CPU if necessary In GPU mode, care must be taken when calling this from multiple cpu threads Only the "GPU Owner" thread may call this when the data is actually on the GPU. Ideally call once from main thread to get data onto the cpu before launching other cpu threads.
 
complexdataGpu ()
 Get a GPU data pointer (must be called from GPU owner thread)
 
const complexdataGpu () const
 Get a const GPU data pointer (must be called from GPU owner thread)
 
size_t nData () const
 number of data points
 
bool isOnGpu () const
 Check where the data is (for #ifdef simplicity exposed even when no GPU_ENABLED)
 
complexbegin ()
 pointer to start of array
 
const complexbegin () const
 const pointer to start of array
 
const complexcbegin () const
 const pointer to start of array
 
complexend ()
 pointer just past end of array
 
const complexend () const
 const pointer just past end of array
 
const complexcend () const
 const pointer just past end of array
 
complexdataPref ()
 
const complexdataPref () const
 
void read (const char *fname)
 binary read from a file
 
void read (FILE *filep)
 binary read from a stream
 
void write (const char *fname) const
 binary-write to a file
 
void write (FILE *filep) const
 binary-write toa stream
 
void read_real (const char *fname)
 binary read real-part from file, setting imaginary parts to 0
 
void read_real (FILE *filep)
 binary read real-part from stream, setting imaginary parts to 0
 
void write_real (const char *fname) const
 binary write real-parts to file
 
void write_real (FILE *filep) const
 binary write real-parts to stream
 
void dump (const char *fname, bool realPartOnly) const
 write as complex or real-part alone and report discarded imaginary part, if any
 
void zero ()
 set all elements to zero
 

Public Attributes

struct matrixScaledTransOp int iStop
 
struct matrixScaledTransOp int int jStart
 
struct matrixScaledTransOp int int int jStop const
 

Additional Inherited Members

- Protected Member Functions inherited from ManagedMemory< complex >
 ManagedMemory ()
 Initialize a valid state, but don't allocate anything.
 
void memFree ()
 Free memory.
 
void memInit (string category, size_t nElem, bool onGpu=false)
 Allocate memory.
 
void memMove (ManagedMemory< complex > &&)
 Steal the other object's data (used for move constructors/assignment)
 

Detailed Description

General complex matrix.


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