mptensor v0.4.0
Parallel Library for Tensor Network Methods
Loading...
Searching...
No Matches
tensor_impl.hpp File Reference

Implementation of tensor class. More...

#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <vector>
#include "complex.hpp"
#include "index.hpp"
#include "matrix.hpp"
#include "tensor.hpp"
Include dependency graph for tensor_impl.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  mptensor
 
namespace  mptensor::debug
 Namespace for debugging.
 

Functions

bool mptensor::is_no_transpose (const Axes &axes, const Axes &axes_map, size_t rank)
 
bool mptensor::debug::check_total_size (const Shape &s1, const Shape &s2)
 
bool mptensor::debug::check_extend (const Shape &s_old, const Shape &s_new)
 
bool mptensor::debug::check_transpose_axes (const Axes &axes, size_t rank)
 
bool mptensor::debug::check_svd_axes (const Axes &axes_row, const Axes &axes_col, size_t rank)
 
bool mptensor::debug::check_trace_axes (const Axes &axes_1, const Axes &axes_2, size_t rank)
 
bool mptensor::debug::check_trace_axes (const Axes &axes_a, const Axes &axes_b, const Shape &shape_a, const Shape &shape_b)
 
bool mptensor::debug::check_contract_axes (const Axes &axes_1, const Axes &axes_2, size_t rank)
 
bool mptensor::debug::check_square (const Shape &shape, size_t urank)
 
template<template< typename > class Matrix, typename C >
Tensor< Matrix, Cmptensor::transpose (Tensor< Matrix, C > T, const Axes &axes)
 Transposition of tensor with lazy evaluation.
 
template<template< typename > class Matrix, typename C >
Tensor< Matrix, Cmptensor::transpose (const Tensor< Matrix, C > &T, const Axes &axes, size_t urank_new)
 Transposition of tensor without lazy evaluation.
 
template<template< typename > class Matrix, typename C >
Tensor< Matrix, Cmptensor::reshape (const Tensor< Matrix, C > &T, const Shape &shape_new)
 Change the shape of tensor.
 
template<template< typename > class Matrix, typename C >
Tensor< Matrix, Cmptensor::slice (const Tensor< Matrix, C > &T, size_t n_axes, size_t i_begin, size_t i_end)
 Slice a tensor.
 
template<template< typename > class Matrix, typename C >
Tensor< Matrix, Cmptensor::slice (const Tensor< Matrix, C > &T, const Index &index_begin, const Index &index_end)
 Slice a tensor.
 
template<template< typename > class Matrix, typename C >
Tensor< Matrix, Cmptensor::extend (const Tensor< Matrix, C > &T, const Shape &shape_new)
 Extend the size of a tensor.
 
template<template< typename > class Matrix, typename C >
C mptensor::trace (const Tensor< Matrix, C > &M)
 Trace of matrix (rank-2 tensor)
 
template<template< typename > class Matrix, typename C >
C mptensor::trace (const Tensor< Matrix, C > &T, const Axes &axes_1, const Axes &axes_2)
 Full trace of tensor.
 
template<template< typename > class Matrix, typename C >
C mptensor::trace (const Tensor< Matrix, C > &A, const Tensor< Matrix, C > &B, const Axes &axes_a, const Axes &axes_b)
 Full contraction of two tensors.
 
template<template< typename > class Matrix, typename C >
Tensor< Matrix, Cmptensor::contract (const Tensor< Matrix, C > &T, const Axes &axes_1, const Axes &axes_2)
 Partial trace of tensor.
 
template<template< typename > class Matrix, typename C >
Tensor< Matrix, Cmptensor::kron (const Tensor< Matrix, C > &a, const Tensor< Matrix, C > &b)
 Compute the Kronecker product.
 
template<template< typename > class Matrix, typename C >
Tensor< Matrix, Cmptensor::tensordot (const Tensor< Matrix, C > &a, const Tensor< Matrix, C > &b, const Axes &axes_a, const Axes &axes_b)
 Compute tensor dot product.
 
template<template< typename > class Matrix, typename C >
int mptensor::svd (const Tensor< Matrix, C > &a, std::vector< double > &s)
 Singular value decomposition for rank-2 tensor (matrix)
 
template<template< typename > class Matrix, typename C >
int mptensor::svd (const Tensor< Matrix, C > &a, Tensor< Matrix, C > &u, std::vector< double > &s, Tensor< Matrix, C > &vt)
 Singular value decomposition for rank-2 tensor (matrix)
 
template<template< typename > class Matrix, typename C >
int mptensor::svd (const Tensor< Matrix, C > &a, const Axes &axes_row, const Axes &axes_col, std::vector< double > &s)
 Singular value decomposition for tensor.
 
template<template< typename > class Matrix, typename C >
int mptensor::svd (const Tensor< Matrix, C > &a, const Axes &axes_row, const Axes &axes_col, Tensor< Matrix, C > &u, std::vector< double > &s, Tensor< Matrix, C > &vt)
 Singular value decomposition for tensor.
 
template<template< typename > class Matrix, typename C >
int mptensor::psvd (const Tensor< Matrix, C > &a, std::vector< double > &s, const size_t target_rank)
 Partial SVD for rank-2 tensor (matrix)
 
template<template< typename > class Matrix, typename C >
int mptensor::psvd (const Tensor< Matrix, C > &a, Tensor< Matrix, C > &u, std::vector< double > &s, Tensor< Matrix, C > &vt, const size_t target_rank)
 Partial SVD for rank-2 tensor (matrix)
 
template<template< typename > class Matrix, typename C >
int mptensor::psvd (const Tensor< Matrix, C > &a, const Axes &axes_row, const Axes &axes_col, std::vector< double > &s, const size_t target_rank)
 Partial SVD for tensor.
 
template<template< typename > class Matrix, typename C >
int mptensor::psvd (const Tensor< Matrix, C > &a, const Axes &axes_row, const Axes &axes_col, Tensor< Matrix, C > &u, std::vector< double > &s, Tensor< Matrix, C > &vt, const size_t target_rank)
 Partial SVD for tensor.
 
template<template< typename > class Matrix, typename C >
int mptensor::qr (const Tensor< Matrix, C > &a, Tensor< Matrix, C > &q, Tensor< Matrix, C > &r)
 QR decomposition of matrix (rank-2 tensor)
 
template<template< typename > class Matrix, typename C >
int mptensor::qr (const Tensor< Matrix, C > &a, const Axes &axes_row, const Axes &axes_col, Tensor< Matrix, C > &q, Tensor< Matrix, C > &r)
 QR decomposition of tensor.
 
template<template< typename > class Matrix, typename C >
int mptensor::eigh (const Tensor< Matrix, C > &a, std::vector< double > &eigval, Tensor< Matrix, C > &eigvec)
 
template<template< typename > class Matrix, typename C >
int mptensor::eigh (const Tensor< Matrix, C > &a, std::vector< double > &eigval)
 
template<template< typename > class Matrix, typename C >
int mptensor::eigh (const Tensor< Matrix, C > &a, const Axes &axes_row, const Axes &axes_col, std::vector< double > &eigval, Tensor< Matrix, C > &eigvec)
 
template<template< typename > class Matrix, typename C >
int mptensor::eigh (const Tensor< Matrix, C > &a, const Axes &axes_row, const Axes &axes_col, std::vector< double > &w)
 Compute the eigenvalues of a complex Hermitian or real symmetric tensor.
 
template<template< typename > class Matrix, typename C >
int mptensor::eigh (const Tensor< Matrix, C > &a, const Axes &axes_row_a, const Axes &axes_col_a, const Tensor< Matrix, C > &b, const Axes &axes_row_b, const Axes &axes_col_b, std::vector< double > &eigval, Tensor< Matrix, C > &eigvec)
 
template<template< typename > class Matrix, typename C >
int mptensor::eig (const Tensor< Matrix, C > &a, std::vector< complex > &w, Tensor< Matrix, complex > &z)
 Compute the eigenvalues and eigenvectors of a general matrix (rank-2 tensor)
 
template<template< typename > class Matrix, typename C >
int mptensor::eig (const Tensor< Matrix, C > &a, std::vector< complex > &w)
 Compute only the eigenvalues of a general matrix (rank-2 tensor)
 
template<template< typename > class Matrix, typename C >
int mptensor::eig (const Tensor< Matrix, C > &a, const Axes &axes_row, const Axes &axes_col, std::vector< complex > &w, Tensor< Matrix, complex > &z)
 Compute the eigenvalues and eigenvectors of a general tensor.
 
template<template< typename > class Matrix, typename C >
int mptensor::eig (const Tensor< Matrix, C > &a, const Axes &axes_row, const Axes &axes_col, std::vector< complex > &w)
 Compute the eigenvalues of a general tensor.
 
template<template< typename > class Matrix, typename C >
int mptensor::solve (const Tensor< Matrix, C > &a, const std::vector< C > &b, std::vector< C > &x)
 Solve linear equation \( A\vec{x}=\vec{b}\).
 
template<template< typename > class Matrix, typename C >
int mptensor::solve (const Tensor< Matrix, C > &a, const Tensor< Matrix, C > &b, Tensor< Matrix, C > &x)
 Solve linear equation \( AX=B\).
 
template<template< typename > class Matrix, typename C >
int mptensor::solve (const Tensor< Matrix, C > &a, const Tensor< Matrix, C > &b, Tensor< Matrix, C > &x, const Axes &axes_row_a, const Axes &axes_col_a, const Axes &axes_row_b, const Axes &axes_col_b)
 Solve linear equation \( AX=B\).
 
template<template< typename > class Matrix, typename C >
Tensor< Matrix, Cmptensor::operator+ (Tensor< Matrix, C > rhs)
 Unary plus.
 
template<template< typename > class Matrix, typename C >
Tensor< Matrix, Cmptensor::operator- (Tensor< Matrix, C > rhs)
 Unary minus.
 
template<template< typename > class Matrix, typename C >
Tensor< Matrix, Cmptensor::operator+ (Tensor< Matrix, C > lhs, const Tensor< Matrix, C > &rhs)
 Addition.
 
template<template< typename > class Matrix, typename C >
Tensor< Matrix, Cmptensor::operator- (Tensor< Matrix, C > lhs, const Tensor< Matrix, C > &rhs)
 Subtraction.
 
template<template< typename > class Matrix, typename C , typename D >
Tensor< Matrix, Cmptensor::operator* (Tensor< Matrix, C > lhs, D rhs)
 Tensor-scalar multiplication.
 
template<template< typename > class Matrix, typename C , typename D >
Tensor< Matrix, Cmptensor::operator/ (Tensor< Matrix, C > lhs, D rhs)
 Scalar division.
 
template<template< typename > class Matrix, typename C , typename D >
Tensor< Matrix, Cmptensor::operator* (D lhs, Tensor< Matrix, C > rhs)
 Scalar-tensor multiplication.
 
template<template< typename > class Matrix, typename C >
double mptensor::max (const Tensor< Matrix, C > &t)
 Return the maximum element. For complex, same as max_abs().
 
template<template< typename > class Matrix, typename C >
double mptensor::min (const Tensor< Matrix, C > &t)
 Return the minimum element. For complex, same as min_abs().
 
template<template< typename > class Matrix, typename C >
double mptensor::max_abs (const Tensor< Matrix, C > &t)
 Return maximum of the absolute value of an element.
 
template<template< typename > class Matrix, typename C >
double mptensor::min_abs (const Tensor< Matrix, C > &t)
 Return minimum of the absolute value of an element.
 
template<template< typename > class Matrix, typename C >
std::ostream & mptensor::operator<< (std::ostream &out, const Tensor< Matrix, C > &t)
 Output elements of tensor in numpy style.
 

Detailed Description

Implementation of tensor class.

Author
Satoshi Morita morit.nosp@m.a@is.nosp@m.sp.u-.nosp@m.toky.nosp@m.o.ac..nosp@m.jp
Date
Jan 14 2015