Psi4
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
psi::Vector Class Reference

#include <vector.h>

Public Types

typedef std::vector< double >
::iterator 
iterator
 
typedef std::vector< double >
::const_iterator 
const_iterator
 

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...
 
virtual ~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 ()
 
void set (double *vec)
 Sets the vector_ to the data in vec. More...
 
double * pointer (int h=0)
 Returns a pointer to irrep h. More...
 
const double * pointer (int h=0) const
 
double get (int h, int m)
 Returns a single element value. More...
 
void set (int h, int m, double val)
 Sets a single element value. More...
 
double get (int m)
 Returns a single element value. More...
 
void set (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 std::vector< double > &rhs)
 
void add (const std::shared_ptr< Vector > &other)
 Adds other vector to this. More...
 
void add (const Vector &other)
 
void subtract (const std::shared_ptr< Vector > &other)
 Subtracts other vector from this. More...
 
void subtract (const Vector &other)
 
void axpy (double scale, const std::shared_ptr< Vector > &other)
 
void axpy (double scale, const Vector &other)
 
void zero ()
 Zeros the vector out. More...
 
double & operator() (int i)
 
const double & operator() (int i) const
 
double & operator[] (int i)
 
const double & operator[] (int i) const
 
double pyget (const py::tuple &key)
 
void pyset (const py::tuple &key, double value)
 
double pyget (int key)
 
void pyset (int key, double value)
 
double * to_block_vector ()
 Returns a copy of the vector_. More...
 
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=NULL) 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 std::shared_ptr< Vector > &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 (const double &sc)
 Scale the elements of the vector. More...
 
void send ()
 
void recv ()
 
void bcast (int broadcaster)
 
void sum ()
 
void set_numpy_shape (std::vector< int > shape)
 
std::vector< int > numpy_shape ()
 
std::vector< py::buffer_info > array_interface ()
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
iterator begin_irrep (int h)
 
iterator end_irrep (int h)
 

Static Public Member Functions

static std::shared_ptr< Vectorcreate (const std::string &name, const Dimension &dim)
 

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...
 

Friends

class Matrix
 

Detailed Description

Member Typedef Documentation

typedef std::vector<double>::const_iterator psi::Vector::const_iterator
typedef std::vector<double>::iterator psi::Vector::iterator

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 
)

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

psi::Vector::Vector ( int  dim)

Constructor, convenience for 1 irrep.

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

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

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

Constructor, convenience for 1 irrep.

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

Constructor, takes Dimension object.

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

Constructor, takes Dimension object.

psi::Vector::~Vector ( )
virtual

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 std::vector< double > &  rhs)
void psi::Vector::add ( const std::shared_ptr< Vector > &  other)

Adds other vector to this.

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

Allocates vector_.

std::vector< py::buffer_info > psi::Vector::array_interface ( )
void psi::Vector::assign_pointer_offsets ( )
protected

Assign pointer offsets in vector_ from v_.

void psi::Vector::axpy ( double  scale,
const std::shared_ptr< Vector > &  other 
)
void psi::Vector::axpy ( double  scale,
const Vector other 
)
void psi::Vector::bcast ( int  broadcaster)
iterator psi::Vector::begin ( )
inline

Returns the starting iterator for the entire v_.

const_iterator psi::Vector::begin ( ) const
inline
iterator psi::Vector::begin_irrep ( int  h)
inline

Returns the starting iterator for irrep h.

Vector * psi::Vector::clone ( void  )
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_.

SharedVector psi::Vector::create ( const std::string &  name,
const Dimension dim 
)
static

Convenient creation function return SharedMatrix

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)
iterator psi::Vector::end ( )
inline

Returns the ending iterator for the entire v_.

const_iterator psi::Vector::end ( ) const
inline
iterator psi::Vector::end_irrep ( int  h)
inline

Returns the starting iterator for irrep h.

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

General matrix vector multiplication.

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

Returns a single element value.

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

Returns a single element value.

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 ( void  ) 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 = NULL 
) 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.

double psi::Vector::pyget ( const py::tuple &  key)
double psi::Vector::pyget ( int  key)
void psi::Vector::pyset ( const py::tuple &  key,
double  value 
)
void psi::Vector::pyset ( int  key,
double  value 
)
void psi::Vector::recv ( )
void psi::Vector::release ( )
protected

Releases vector_.

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

Scale the elements of the vector.

void psi::Vector::send ( )
void psi::Vector::set ( double *  vec)

Sets the vector_ to the data in vec.

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

Sets a single element value.

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

Sets a single element value.

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 std::shared_ptr< Vector > &  other)

Subtracts other vector from this.

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

Performs element-by-element sum of all data from all nodes.

RMR-See note in Matrix::sum()

double psi::Vector::sum_of_squares ( )
double * psi::Vector::to_block_vector ( )

Returns a copy of the vector_.

double psi::Vector::vector_dot ( const std::shared_ptr< Vector > &  other)

Vector dot product.

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

Zeros the vector out.

Friends And Related Function Documentation

friend class Matrix
friend

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: