Psi4
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
psi::Vector Class Referencefinal

#include <vector.h>

Public Member Functions

 Vector ()
 Default constructor, zeros everything out. More...
 
 Vector (const Vector &copy)
 Copy constructor. More...
 
 Vector (int nirrep, int *dimpi)
 
 Vector (int dim)
 Constructor, convenience for 1 irrep. More...
 
 Vector (const std::string &name, int nirrep, int *dimpi)
 
 Vector (const std::string &name, int dim)
 Constructor, convenience for 1 irrep. More...
 
 Vector (const Dimension &dimpi)
 Constructor, takes Dimension object. More...
 
 Vector (const std::string &name, const Dimension &dimpi)
 Constructor, takes Dimension object. More...
 
 ~Vector ()
 Destructor, frees memory. More...
 
void init (int nirrep, int *dimpi)
 
void init (int nirrep, const int *dimpi, const std::string &name="")
 
void init (const Dimension &v)
 
Vectorclone ()
 
double * pointer (int h=0)
 Returns a pointer to irrep h. More...
 
const double * pointer (int h=0) const
 
double get (int m) const
 Returns a single element value. More...
 
void set (int m, double val)
 Sets a single element value. More...
 
double get (int h, int m) const
 Returns a single element value. More...
 
void set (int h, int m, double val)
 Sets a single element value. More...
 
void add (int m, double val)
 
void add (int h, int m, double val)
 
void add (const SharedVector &other)
 Adds other vector to this. More...
 
void add (const Vector &other)
 
void subtract (const SharedVector &other)
 Subtracts other vector from this. More...
 
void subtract (const Vector &other)
 
void axpy (double scale, const SharedVector &other)
 
void axpy (double scale, const Vector &other)
 
void zero ()
 Zeros the vector out. More...
 
SharedVector get_block (const Slice &slice)
 
void set_block (const Slice &slice, SharedVector block)
 
double & operator() (int i)
 
const double & operator() (int i) const
 
double & operator[] (int i)
 
const double & operator[] (int i) const
 
int dim (int h=0) const
 Returns the dimension per irrep h. More...
 
const Dimensiondimpi () const
 Returns the dimension array. More...
 
int nirrep () const
 Returns the number of irreps. More...
 
void set_name (const std::string &name)
 
std::string name () const
 
void print_out ()
 Python compatible printer. More...
 
void print (std::string outfile="outfile", const char *extra=nullptr) const
 
void copy (const Vector *rhs)
 Copies rhs to this. More...
 
void copy (const Vector &rhs)
 Copies rhs to this. More...
 
void gemv (bool transa, double alpha, Matrix *A, Vector *X, double beta)
 General matrix vector multiplication. More...
 
double vector_dot (const SharedVector &other)
 Vector dot product. More...
 
double vector_dot (const Vector &other)
 
double dot (Vector *X)
 
double norm ()
 Vector norm. More...
 
double sum_of_squares ()
 
double rms ()
 
void scale (double sc)
 Scale the elements of the vector. More...
 
void set_numpy_shape (std::vector< int > shape)
 
std::vector< int > numpy_shape ()
 
 PSI_DEPRECATED ("Using `Vector::create` instead of `auto my_vec = std::make_shared<Vector>(name, dim);` ""is deprecated, and in 1.4 it will ""stop working") static SharedVector create(const std
 

Protected Member Functions

void alloc ()
 Allocates vector_. More...
 
void release ()
 Releases vector_. More...
 
void copy_from (const Vector &other)
 Copies data to vector_. More...
 
void assign_pointer_offsets ()
 Assign pointer offsets in vector_ from v_. More...
 

Protected Attributes

std::vector< double > v_
 Actual data, of size dimpi_.sum() More...
 
std::vector< double * > vector_
 Pointer offsets into v_, of size dimpi_.n() More...
 
int nirrep_
 Number of irreps. More...
 
Dimension dimpi_
 Dimensions per irrep. More...
 
std::string name_
 Name. More...
 
std::vector< int > numpy_shape_
 Numpy Shape. More...
 

Detailed Description

Constructor & Destructor Documentation

psi::Vector::Vector ( )

Default constructor, zeros everything out.

psi::Vector::Vector ( const Vector copy)

Copy constructor.

psi::Vector::Vector ( int  nirrep,
int *  dimpi 
)
explicit

Constructor, allocates memory (this should be deprecated in favor of the Dimension-based version)

psi::Vector::Vector ( int  dim)
explicit

Constructor, convenience for 1 irrep.

psi::Vector::Vector ( const std::string &  name,
int  nirrep,
int *  dimpi 
)
explicit

Constructor, allocates memory (this should be deprecated in favor of the Dimension-based version)

psi::Vector::Vector ( const std::string &  name,
int  dim 
)
explicit

Constructor, convenience for 1 irrep.

psi::Vector::Vector ( const Dimension dimpi)
explicit

Constructor, takes Dimension object.

psi::Vector::Vector ( const std::string &  name,
const Dimension dimpi 
)
explicit

Constructor, takes Dimension object.

psi::Vector::~Vector ( )

Destructor, frees memory.

Member Function Documentation

void psi::Vector::add ( int  m,
double  val 
)
inline
void psi::Vector::add ( int  h,
int  m,
double  val 
)
inline
void psi::Vector::add ( const SharedVector other)

Adds other vector to this.

void psi::Vector::add ( const Vector other)
void psi::Vector::alloc ( )
protected

Allocates vector_.

void psi::Vector::assign_pointer_offsets ( )
protected

Assign pointer offsets in vector_ from v_.

void psi::Vector::axpy ( double  scale,
const SharedVector other 
)
void psi::Vector::axpy ( double  scale,
const Vector other 
)
Vector * psi::Vector::clone ( )
void psi::Vector::copy ( const Vector rhs)

Copies rhs to this.

void psi::Vector::copy ( const Vector rhs)

Copies rhs to this.

void psi::Vector::copy_from ( const Vector other)
protected

Copies data to vector_.

int psi::Vector::dim ( int  h = 0) const
inline

Returns the dimension per irrep h.

const Dimension& psi::Vector::dimpi ( ) const
inline

Returns the dimension array.

double psi::Vector::dot ( Vector X)
void psi::Vector::gemv ( bool  transa,
double  alpha,
Matrix A,
Vector X,
double  beta 
)

General matrix vector multiplication.

double psi::Vector::get ( int  m) const
inline

Returns a single element value.

double psi::Vector::get ( int  h,
int  m 
) const
inline

Returns a single element value.

SharedVector psi::Vector::get_block ( const Slice slice)

Get a vector block

Parameters
sliceVector slice
Returns
SharedVector object
void psi::Vector::init ( int  nirrep,
int *  dimpi 
)
void psi::Vector::init ( int  nirrep,
const int *  dimpi,
const std::string &  name = "" 
)
void psi::Vector::init ( const Dimension v)
std::string psi::Vector::name ( ) const
inline

Gets the name of the matrix.

int psi::Vector::nirrep ( ) const
inline

Returns the number of irreps.

double psi::Vector::norm ( )

Vector norm.

std::vector<int> psi::Vector::numpy_shape ( )
inline
double& psi::Vector::operator() ( int  i)
inline
const double& psi::Vector::operator() ( int  i) const
inline
double& psi::Vector::operator[] ( int  i)
inline
const double& psi::Vector::operator[] ( int  i) const
inline
double* psi::Vector::pointer ( int  h = 0)
inline

Returns a pointer to irrep h.

const double* psi::Vector::pointer ( int  h = 0) const
inline
void psi::Vector::print ( std::string  outfile = "outfile",
const char *  extra = nullptr 
) const

Print the matrix using print_mat

Parameters
outfileFile point to use, defaults to Psi4's outfile.
extraWhen printing the name of the 'extra' will be printing after the name.
void psi::Vector::print_out ( )
inline

Python compatible printer.

psi::Vector::PSI_DEPRECATED ( "Using `Vector::create` instead of `auto  my_vec = std::make_shared<Vector>(namedim);` " "is deprecated,
and in 1.4 it will" "stop working"   
) const
inline
void psi::Vector::release ( )
protected

Releases vector_.

double psi::Vector::rms ( )
void psi::Vector::scale ( double  sc)

Scale the elements of the vector.

void psi::Vector::set ( int  m,
double  val 
)
inline

Sets a single element value.

void psi::Vector::set ( int  h,
int  m,
double  val 
)
inline

Sets a single element value.

void psi::Vector::set_block ( const Slice slice,
SharedVector  block 
)

Set a vector block

Parameters
sliceVector slice
blockthe SharedVector object block to set
void psi::Vector::set_name ( const std::string &  name)
inline

Sets the name of the vector, used in print(...)

Parameters
nameNew name to use.
void psi::Vector::set_numpy_shape ( std::vector< int >  shape)
inline

Adds accessability to the matrix shape for numpy

void psi::Vector::subtract ( const SharedVector other)

Subtracts other vector from this.

void psi::Vector::subtract ( const Vector other)
double psi::Vector::sum_of_squares ( )
double psi::Vector::vector_dot ( const SharedVector other)

Vector dot product.

double psi::Vector::vector_dot ( const Vector other)
void psi::Vector::zero ( )

Zeros the vector out.

Member Data Documentation

Dimension psi::Vector::dimpi_
protected

Dimensions per irrep.

std::string psi::Vector::name_
protected

Name.

int psi::Vector::nirrep_
protected

Number of irreps.

std::vector<int> psi::Vector::numpy_shape_
protected

Numpy Shape.

std::vector<double> psi::Vector::v_
protected

Actual data, of size dimpi_.sum()

std::vector<double *> psi::Vector::vector_
protected

Pointer offsets into v_, of size dimpi_.n()


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