openjij
Framework for the Ising model and QUBO.
Loading...
Searching...
No Matches
openjij::graph::CSRSparse< FloatType > Class Template Reference

CSRSparse graph: just store CSR Sparse Matrix (Eigen::Sparse) The Hamiltonian is like. More...

#include <csr_sparse.hpp>

Inheritance diagram for openjij::graph::CSRSparse< FloatType >:
Collaboration diagram for openjij::graph::CSRSparse< FloatType >:

Public Types

using Interactions
 interaction type
using value_type = FloatType
 float type

Public Member Functions

 CSRSparse (const Interactions &interaction)
 CSRSparse constructor.
 CSRSparse (const CSRSparse< FloatType > &)=default
 CSRSparse copy constructor.
 CSRSparse (CSRSparse< FloatType > &&)=default
 CSRSparse move constructor.
FloatType calc_energy (const Spins &spins) const
 calculate total energy
FloatType calc_energy (const Eigen::Matrix< FloatType, Eigen::Dynamic, 1, Eigen::ColMajor > &spins) const
FloatType energy (const Spins &spins) const
 calculate total energy
FloatType energy (const Eigen::Matrix< FloatType, Eigen::Dynamic, 1, Eigen::ColMajor > &spins) const
const Interactions get_interactions () const
 get interactions (Eigen Matrix)
Public Member Functions inherited from openjij::graph::Graph
 Graph (std::size_t num_spins)
 Graph constructor.
template<typename RandomNumberEngine>
const Spins gen_spin (RandomNumberEngine &random_numder_engine) const
 generate spins randomly.
template<typename RandomNumberEngine>
const Binaries gen_binary (RandomNumberEngine &random_numder_engine) const
 generate spins randomly.
std::size_t get_num_spins () const noexcept
 get number of spins
std::size_t size () const noexcept
 get number of spins

Private Attributes

Interactions _J
 interactions (the number of intereactions is num_spins*(num_spins+1)/2).

Detailed Description

template<typename FloatType>
class openjij::graph::CSRSparse< FloatType >

CSRSparse graph: just store CSR Sparse Matrix (Eigen::Sparse) The Hamiltonian is like.

\[H = \sum_{i<j}J_{ij} \sigma_i \sigma_j + \sum_{i}h_{i} \sigma_i \]

Template Parameters
FloatTypefloating-point type

Member Typedef Documentation

◆ Interactions

template<typename FloatType>
using openjij::graph::CSRSparse< FloatType >::Interactions
Initial value:
Eigen::SparseMatrix<FloatType, Eigen::RowMajor>

interaction type

◆ value_type

template<typename FloatType>
using openjij::graph::CSRSparse< FloatType >::value_type = FloatType

float type

Constructor & Destructor Documentation

◆ CSRSparse() [1/3]

template<typename FloatType>
openjij::graph::CSRSparse< FloatType >::CSRSparse ( const Interactions & interaction)
inlineexplicit

CSRSparse constructor.

The input matrix must have the form:

\[\begin{pmatrix} J_{0,0} & J_{0,1} & \cdots & J_{0,N-1} & h_{0}\\ 0 & J_{1,1} & \cdots & J_{1,N-1} & h_{1}\\ \vdots & \vdots & \vdots & \vdots & \vdots \\ 0 & 0 & \cdots & J_{N-1,N-1} & h_{N-1}\\ 0 & 0 & \cdots & 0 & 1 \\ \end{pmatrix} \]

Parameters
interactioninput matrix

References _J, and openjij::graph::Graph::Graph().

Referenced by CSRSparse(), and CSRSparse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CSRSparse() [2/3]

template<typename FloatType>
openjij::graph::CSRSparse< FloatType >::CSRSparse ( const CSRSparse< FloatType > & )
default

CSRSparse copy constructor.

References CSRSparse().

Here is the call graph for this function:

◆ CSRSparse() [3/3]

template<typename FloatType>
openjij::graph::CSRSparse< FloatType >::CSRSparse ( CSRSparse< FloatType > && )
default

CSRSparse move constructor.

References CSRSparse().

Here is the call graph for this function:

Member Function Documentation

◆ calc_energy() [1/2]

template<typename FloatType>
FloatType openjij::graph::CSRSparse< FloatType >::calc_energy ( const Eigen::Matrix< FloatType, Eigen::Dynamic, 1, Eigen::ColMajor > & spins) const
inline

References energy().

Here is the call graph for this function:

◆ calc_energy() [2/2]

template<typename FloatType>
FloatType openjij::graph::CSRSparse< FloatType >::calc_energy ( const Spins & spins) const
inline

calculate total energy

Parameters
spins
Deprecated
use energy(spins)
Returns
corresponding energy

References energy().

Referenced by openjij::declare_CSRSparse().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ energy() [1/2]

template<typename FloatType>
FloatType openjij::graph::CSRSparse< FloatType >::energy ( const Eigen::Matrix< FloatType, Eigen::Dynamic, 1, Eigen::ColMajor > & spins) const
inline

References energy(), and openjij::graph::Graph::get_num_spins().

Here is the call graph for this function:

◆ energy() [2/2]

template<typename FloatType>
FloatType openjij::graph::CSRSparse< FloatType >::energy ( const Spins & spins) const
inline

calculate total energy

Parameters
spins
Returns
corresponding energy

References _J, and openjij::graph::Graph::get_num_spins().

Referenced by calc_energy(), calc_energy(), and energy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_interactions()

template<typename FloatType>
const Interactions openjij::graph::CSRSparse< FloatType >::get_interactions ( ) const
inline

get interactions (Eigen Matrix)

The returned matrix has the following symmetric form:

\[\begin{pmatrix} J_{0,0} & J_{0,1} & \cdots & J_{0,N-1} & h_{0}\\ J_{0,1} & J_{1,1} & \cdots & J_{1,N-1} & h_{1}\\ \vdots & \vdots & \vdots & \vdots & \vdots \\ J_{0,N-1} & J_{N-1,1} & \cdots & J_{N-1,N-1} & h_{N-1}\\ h_{0} & h_{1} & \cdots & h_{N-1} & 1 \\ \end{pmatrix} \]

Returns
Eigen Matrix

Referenced by openjij::declare_CSRSparse().

Here is the caller graph for this function:

Member Data Documentation

◆ _J

template<typename FloatType>
Interactions openjij::graph::CSRSparse< FloatType >::_J
private

interactions (the number of intereactions is num_spins*(num_spins+1)/2).

The stored matrix has the following triangular form:

\[\begin{pmatrix} J_{0,0} & J_{0,1} & \cdots & J_{0,N-1} & h_{0}\\ 0 & J_{1,1} & \cdots & J_{1,N-1} & h_{1}\\ \vdots & \vdots & \vdots & \vdots & \vdots \\ 0 & 0 & \cdots & J_{N-1,N-1} & h_{N-1}\\ 0 & 0 & \cdots & 0 & 1 \\ \end{pmatrix} \]

Referenced by CSRSparse(), and energy().


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