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

#include <thce.h>

Inheritance diagram for psi::CoreTensor:
psi::Tensor

Public Member Functions

 CoreTensor (const std::string &name, std::vector< std::string > &dimensions, std::vector< int > &sizes, double *data=NULL, bool trust=false)
 Master constructor. More...
 
virtual ~CoreTensor ()
 Master destructor. More...
 
virtual bool core () const
 Is this a core tensor? More...
 
virtual bool disk () const
 Is this a disk tensor? More...
 
virtual bool trust () const
 Is this a trust core tensor? More...
 
virtual bool swapped () const
 Is this a swapped-out core tensor? More...
 
virtual void swap_check () const
 Throw an exception if the tensor is swapped out or disk based. More...
 
virtual size_t core_doubles () const
 How many core doubles are currently allocated by this tensor? More...
 
virtual size_t disk_doubles () const
 How many disk doubles are currently allocated by this tensor? More...
 
virtual void print (std::string fh="outfile", int level=2) const
 Print the full tensor data in scalar/vector/matrix/pages style if print >= 2. More...
 
virtual double * pointer () const
 Data underlying this Tensor (careful, returns NULL if swapped) More...
 
virtual FILE * file_pointer ()
 File pointer underlying this Tensor (careful, returns NULL if not swapped, mirror not guaranteed) More...
 
virtual void swap_out (bool changed=true)
 Swap this tensor out to disk (if existing file, only write if changed) More...
 
virtual void swap_in (bool read=true)
 Swap this tensor in to core (if read is false, allocate with zeros) More...
 
virtual void zero ()
 Zero the tensor out. More...
 
virtual void scale (double val)
 Scale the tensor by val. More...
 
virtual void set_data (double *data)
 Copy contents of data (ignores active dims) More...
 
virtual void set_pointer (double *data)
 Update the trust pointer to data (throws if not trust) More...
 
virtual void add (std::shared_ptr< Tensor > A, double alpha=1.0, double beta=0.0)
 Direct elementwise generalized DAXPY: C = alpha * A + beta * C (ignores active dims) More...
 
virtual void permute (std::shared_ptr< Tensor > A, std::vector< int > &topology)
 
virtual void contract (std::shared_ptr< Tensor > A, std::shared_ptr< Tensor > B, std::vector< std::tuple< std::string, int, int, int > > &topology, double alpha=1.0, double beta=0.0)
 
- Public Member Functions inherited from psi::Tensor
 Tensor (const std::string &name, std::vector< std::string > &dimensions, std::vector< int > &sizes)
 Master constructor. More...
 
virtual ~Tensor ()
 Master destructor. More...
 
std::string name () const
 Name of this Tensor. More...
 
std::string filename () const
 Unique filename of this Tensor. More...
 
size_t numel () const
 Total number of elements in this Tensor. More...
 
int order () const
 Order (number of dimensions) in this Tensor. More...
 
std::vector< std::string > & dimensions ()
 Classes of dimensions. More...
 
std::vector< int > & sizes ()
 Allocated sizes of dimensions. More...
 
std::vector< int > & active_sizes ()
 Active sizes of dimensions. More...
 
void print_header (std::string fh="outfile") const
 Print only name and sizing data. More...
 
virtual void slice (std::shared_ptr< Tensor > A, std::vector< std::tuple< bool, int, int, bool, int, int > > &topology)
 
virtual void set_save (bool save)
 Set save flag in DiskTensor. More...
 

Static Public Member Functions

static std::shared_ptr< Tensorbuild (const std::string &name, double *data=NULL, bool trust=false)
 Order-0 Constructor. More...
 
static std::shared_ptr< Tensorbuild (const std::string &name, const std::string &dimension1, int size1, double *data=NULL, bool trust=false)
 Order-1 Constructor. More...
 
static std::shared_ptr< Tensorbuild (const std::string &name, const std::string &dimension1, int size1, const std::string &dimension2, int size2, double *data=NULL, bool trust=false)
 Order-2 Constructor. More...
 
static std::shared_ptr< Tensorbuild (const std::string &name, const std::string &dimension1, int size1, const std::string &dimension2, int size2, const std::string &dimension3, int size3, double *data=NULL, bool trust=false)
 Order-3 Constructor. More...
 
static std::shared_ptr< Tensorbuild (const std::string &name, const std::string &dimension1, int size1, const std::string &dimension2, int size2, const std::string &dimension3, int size3, const std::string &dimension4, int size4, double *data=NULL, bool trust=false)
 Order-4 Constructor. More...
 

Protected Attributes

bool trust_
 Is this a trust pointer? More...
 
double * data_
 Data underlying this Tensor. More...
 
bool swapped_
 Is this tensor swapped? More...
 
FILE * fh_
 File handle (valid if this tensor has ever been swapped out) More...
 
- Protected Attributes inherited from psi::Tensor
std::string name_
 Name of this Tensor. More...
 
std::string filename_
 Unique filename to prevent disk clash. More...
 
size_t numel_
 Total number of elements in this Tensor. More...
 
int order_
 Order (number of dimensions) in this Tensor. More...
 
std::vector< std::string > dimensions_
 Classes of dimensions. More...
 
std::vector< int > sizes_
 Sizes of dimensions (lda-style) More...
 
std::vector< int > active_sizes_
 Active sizes of dimensions (gimp-style) More...
 

Additional Inherited Members

- Protected Member Functions inherited from psi::Tensor
void set_filename ()
 Set the filename to scratch, PID, namespace, unique ID, name. More...
 

Detailed Description

Class CoreTensor provides functionality for the creation and manipulation of Tensor objects in core memory

Constructor & Destructor Documentation

psi::CoreTensor::CoreTensor ( const std::string &  name,
std::vector< std::string > &  dimensions,
std::vector< int > &  sizes,
double *  data = NULL,
bool  trust = false 
)

Master constructor.

psi::CoreTensor::~CoreTensor ( )
virtual

Master destructor.

Member Function Documentation

void psi::CoreTensor::add ( std::shared_ptr< Tensor A,
double  alpha = 1.0,
double  beta = 0.0 
)
virtual

Direct elementwise generalized DAXPY: C = alpha * A + beta * C (ignores active dims)

Reimplemented from psi::Tensor.

std::shared_ptr< Tensor > psi::CoreTensor::build ( const std::string &  name,
double *  data = NULL,
bool  trust = false 
)
static

Order-0 Constructor.

std::shared_ptr< Tensor > psi::CoreTensor::build ( const std::string &  name,
const std::string &  dimension1,
int  size1,
double *  data = NULL,
bool  trust = false 
)
static

Order-1 Constructor.

std::shared_ptr< Tensor > psi::CoreTensor::build ( const std::string &  name,
const std::string &  dimension1,
int  size1,
const std::string &  dimension2,
int  size2,
double *  data = NULL,
bool  trust = false 
)
static

Order-2 Constructor.

std::shared_ptr< Tensor > psi::CoreTensor::build ( const std::string &  name,
const std::string &  dimension1,
int  size1,
const std::string &  dimension2,
int  size2,
const std::string &  dimension3,
int  size3,
double *  data = NULL,
bool  trust = false 
)
static

Order-3 Constructor.

std::shared_ptr< Tensor > psi::CoreTensor::build ( const std::string &  name,
const std::string &  dimension1,
int  size1,
const std::string &  dimension2,
int  size2,
const std::string &  dimension3,
int  size3,
const std::string &  dimension4,
int  size4,
double *  data = NULL,
bool  trust = false 
)
static

Order-4 Constructor.

void psi::CoreTensor::contract ( std::shared_ptr< Tensor A,
std::shared_ptr< Tensor B,
std::vector< std::tuple< std::string, int, int, int > > &  topology,
double  alpha = 1.0,
double  beta = 0.0 
)
virtual

C = alpha * Op(A, B) + beta * C Topology contains the specification of the contraction, in the form <name,rC,rA,rB>, e.g., C_{j,i,l} = A_{j,i,k} B_{j,l,k} => <j,0,0,0> % Hadamard Dimension (H) <i,1,1,-1> % Outer Dimension (L) <l,2,-1,1> % Outer Dimension (R) <k,-1,2,2> % Inner Dimension (I)

Active dimensions H, L, and R are inherited in C from A and B tensors. If an index is H or I both A and B active dimensions must agree

Reimplemented from psi::Tensor.

virtual bool psi::CoreTensor::core ( ) const
inlinevirtual

Is this a core tensor?

Implements psi::Tensor.

virtual size_t psi::CoreTensor::core_doubles ( ) const
inlinevirtual

How many core doubles are currently allocated by this tensor?

Implements psi::Tensor.

virtual bool psi::CoreTensor::disk ( ) const
inlinevirtual

Is this a disk tensor?

Implements psi::Tensor.

virtual size_t psi::CoreTensor::disk_doubles ( ) const
inlinevirtual

How many disk doubles are currently allocated by this tensor?

Implements psi::Tensor.

virtual FILE* psi::CoreTensor::file_pointer ( )
inlinevirtual

File pointer underlying this Tensor (careful, returns NULL if not swapped, mirror not guaranteed)

Reimplemented from psi::Tensor.

void psi::CoreTensor::permute ( std::shared_ptr< Tensor A,
std::vector< int > &  topology 
)
virtual

Permute from A into C Topology (P) contains rank of index in C indexed by rank in A C_{P=0,P=1,...} = A_{0,1,...}, e.g., C_{k,i,l,j} = A_{i,j,k,l} => [1,3,0,2]

Reimplemented from psi::Tensor.

virtual double* psi::CoreTensor::pointer ( ) const
inlinevirtual

Data underlying this Tensor (careful, returns NULL if swapped)

Reimplemented from psi::Tensor.

void psi::CoreTensor::print ( std::string  fh = "outfile",
int  level = 2 
) const
virtual

Print the full tensor data in scalar/vector/matrix/pages style if print >= 2.

Implements psi::Tensor.

void psi::CoreTensor::scale ( double  val)
virtual

Scale the tensor by val.

Reimplemented from psi::Tensor.

void psi::CoreTensor::set_data ( double *  data)
virtual

Copy contents of data (ignores active dims)

Reimplemented from psi::Tensor.

void psi::CoreTensor::set_pointer ( double *  data)
virtual

Update the trust pointer to data (throws if not trust)

Reimplemented from psi::Tensor.

void psi::CoreTensor::swap_check ( ) const
virtual

Throw an exception if the tensor is swapped out or disk based.

Implements psi::Tensor.

void psi::CoreTensor::swap_in ( bool  read = true)
virtual

Swap this tensor in to core (if read is false, allocate with zeros)

Reimplemented from psi::Tensor.

void psi::CoreTensor::swap_out ( bool  changed = true)
virtual

Swap this tensor out to disk (if existing file, only write if changed)

Reimplemented from psi::Tensor.

virtual bool psi::CoreTensor::swapped ( ) const
inlinevirtual

Is this a swapped-out core tensor?

Implements psi::Tensor.

virtual bool psi::CoreTensor::trust ( ) const
inlinevirtual

Is this a trust core tensor?

Implements psi::Tensor.

void psi::CoreTensor::zero ( void  )
virtual

Zero the tensor out.

Implements psi::Tensor.

Member Data Documentation

double* psi::CoreTensor::data_
protected

Data underlying this Tensor.

FILE* psi::CoreTensor::fh_
protected

File handle (valid if this tensor has ever been swapped out)

bool psi::CoreTensor::swapped_
protected

Is this tensor swapped?

bool psi::CoreTensor::trust_
protected

Is this a trust pointer?


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