openjij
Framework for the Ising model and QUBO.
|
CSRSparse graph: just store CSR Sparse Matrix (Eigen::Sparse) The Hamiltonian is like. More...
#include <csr_sparse.hpp>
Public Types | |
using | Interactions = Eigen::SparseMatrix< FloatType, Eigen::RowMajor > |
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) | |
![]() | |
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). | |
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 \]
FloatType | floating-point type |
using openjij::graph::CSRSparse< FloatType >::Interactions = Eigen::SparseMatrix<FloatType, Eigen::RowMajor> |
interaction type
float type
|
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} \]
interaction | input matrix |
References openjij::graph::CSRSparse< FloatType >::_J, and openjij::graph::json_parse().
|
default |
CSRSparse copy constructor.
|
default |
CSRSparse move constructor.
|
inline |
References openjij::graph::CSRSparse< FloatType >::energy(), and openjij::graph::json_parse().
|
inline |
calculate total energy
spins |
References openjij::graph::CSRSparse< FloatType >::energy().
Referenced by openjij::declare_CSRSparse().
|
inline |
References openjij::graph::CSRSparse< FloatType >::energy(), openjij::graph::Graph::get_num_spins(), and openjij::graph::json_parse().
|
inline |
calculate total energy
spins |
References openjij::graph::CSRSparse< FloatType >::_J, openjij::graph::Graph::get_num_spins(), and openjij::graph::json_parse().
Referenced by openjij::graph::CSRSparse< FloatType >::calc_energy(), openjij::graph::CSRSparse< FloatType >::calc_energy(), and openjij::graph::CSRSparse< FloatType >::energy().
|
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} \]
References openjij::graph::json_parse().
|
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 openjij::graph::CSRSparse< FloatType >::CSRSparse(), and openjij::graph::CSRSparse< FloatType >::energy().