mptensor  v0.3.0
Parallel Library for Tensor Network Methods
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}\). More...
 
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\). More...
 
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\). More...
 

Detailed Description

Functions to solve a linear equation.

Function Documentation

◆ solve() [1/3]

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}\).

Parameters
[in]aThe coefficient square matrix A.
[in]b(global) The right hand side vector \( \vec{b}\).
[out]x(global) The solution \( \vec{x}\).
Returns
Information from linear-algebra library.

◆ solve() [2/3]

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

Parameters
[in]aThe coefficient matrix A. a.shape() = (M,M)
[in]bThe right hand side matrix or vector B. b.shape() = (M,N) or (M)
[out]xThe solution X. Returned shape is identical to b.
Returns
Information from linear-algebra library.

◆ solve() [3/3]

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

Parameters
[in]aThe coefficient tensor A, which is a square matrix after matricization.
[in]bThe right hand side tensor B.
[out]xThe solution X.
[in]axes_row_aAxes in A to reorder to the left.
[in]axes_col_aAxes in A to reorder to the right.
[in]axes_row_bAxes in B to reorder to the left.
[in]axes_col_bAxes in B to reorder to the right.
Returns
Information from linear-algebra library.

The last four arguments define the way of matricization of tensors, A and B. The order of axes in solution X is deterimined by axes_col_a and axes_col_b.

An equation \( \sum_{ik} A_{ijkl}X_{ikm} = B_{mlj} \) can be solved by

solve(A,B,X,Axes(1,3),Axes(0,2),Axes(2,1),Axes(0)),
int solve(const Tensor< Matrix, C > &a, const std::vector< C > &b, std::vector< C > &x)
Solve linear equation .
Definition: tensor_impl.hpp:2447
Index Axes
Definition: tensor.hpp:45

where the equation after reordering is written as \(\sum_{ik} A'_{(jl),(ik)}X_{(ik),(m)} = B'_{(jl),(m)} \).

The length of axes_col_b may be zero. For example,

solve(A,B,X,Axes(0,1),Axes(2,3),Axes(0,1),Axes()),

solves \( \sum_{kl} A_{ijkl} X_{kl} = B_{ij} \).