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

square lattice graph More...

#include <square.hpp>

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

Public Member Functions

Index to_ind (std::int64_t r, std::int64_t c) const
 convert from (row x column) index to global index
 
RowColumn to_rc (Index ind) const
 convert from global index to (row x column) index
 
 Square (std::size_t num_row, std::size_t num_column, FloatType init_val=0)
 square lattice graph constructor
 
 Square (const json &j, std::size_t num_row, std::size_t num_column, FloatType init_val=0)
 Square constructor (from nlohmann::json)
 
 Square (const Square< FloatType > &)=default
 square lattice graph copy constructor
 
 Square (Square< FloatType > &&)=default
 square lattice graph move constructor
 
std::size_t get_num_row () const
 get number of rows
 
std::size_t get_num_column () const
 get number of columns
 
FloatTypeJ (std::size_t r, std::size_t c, Dir dir)
 access J(row, colum, direction)
 
const FloatTypeJ (std::size_t r, std::size_t c, Dir dir) const
 access J(row, colum, direction)
 
FloatTypeh (std::size_t r, std::size_t c)
 access h(row, colum) (local field)
 
const FloatTypeh (std::size_t r, std::size_t c) const
 access h(row, colum) (local field)
 
Spinspin (Spins &spins, std::size_t r, std::size_t c) const
 derive spin value at the index (row x column)
 
const Spinspin (const Spins &spins, std::size_t r, std::size_t c) const
 derive spin value at the index (row x column)
 
- Public Member Functions inherited from openjij::graph::Sparse< FloatType >
 Sparse (std::size_t num_spins, std::size_t num_edges)
 Sparse constructor.
 
 Sparse (std::size_t num_spins)
 Sparse delegate constructor.
 
 Sparse (const json &j, std::size_t num_edges)
 Sparse constructor (from nlohmann::json)
 
 Sparse (const json &j)
 Sparse constructor (from nlohmann::json)
 
 Sparse (const Sparse< FloatType > &)=default
 Sparse copy constructor.
 
 Sparse (Sparse< FloatType > &&)=default
 Sparse move constructor.
 
const Nodesadj_nodes (Index ind) const
 list of adjacent nodes
 
std::size_t get_num_edges () const
 get number of edges
 
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
 
FloatTypeJ (Index i, Index j)
 access J_{ij}
 
const FloatTypeJ (Index i, Index j) const
 access J_{ij}
 
FloatTypeh (Index i)
 access h_{i} (local field)
 
const FloatTypeh (Index i) const
 access h_{i} (local field)
 
- 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 Member Functions

std::size_t mod_r (std::int64_t a) const
 mod function (a mod num_row)
 
std::size_t mod_c (std::int64_t a) const
 mod function (a mod num_column)
 
void _checkpair (Index idx1, Index idx2) const
 check if the pair has a valid connection
 

Private Attributes

FloatType _init_val
 initial value to be set to interactions
 
std::size_t _num_row
 number of rows
 
std::size_t _num_column
 number of columns
 

Additional Inherited Members

- Public Types inherited from openjij::graph::Sparse< FloatType >
using Interactions = std::unordered_map< std::pair< Index, Index >, FloatType, utility::PairHash >
 interaction type
 
using value_type = FloatType
 float type
 

Detailed Description

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

square lattice graph

Template Parameters
FloatTypefloating-point type (default is double)

Constructor & Destructor Documentation

◆ Square() [1/4]

template<typename FloatType >
openjij::graph::Square< FloatType >::Square ( std::size_t  num_row,
std::size_t  num_column,
FloatType  init_val = 0 
)
inline

square lattice graph constructor

Parameters
num_rownumber of rows
num_columnnumber of columns
init_valinitial value set to interaction (default: 0)

References openjij::graph::Square< FloatType >::_init_val, openjij::graph::Square< FloatType >::_num_column, openjij::graph::Square< FloatType >::_num_row, openjij::graph::Sparse< FloatType >::J(), openjij::graph::json_parse(), and openjij::graph::Square< FloatType >::to_ind().

Here is the call graph for this function:

◆ Square() [2/4]

template<typename FloatType >
openjij::graph::Square< FloatType >::Square ( const json j,
std::size_t  num_row,
std::size_t  num_column,
FloatType  init_val = 0 
)
inline

Square constructor (from nlohmann::json)

Parameters
jJSON object
num_rownumber of rows
num_columnnumber of columns
init_valinitial value set to interaction (default: 0)

References openjij::graph::Square< FloatType >::_checkpair(), openjij::graph::Sparse< FloatType >::h(), openjij::graph::Sparse< FloatType >::J(), and openjij::graph::json_parse().

Here is the call graph for this function:

◆ Square() [3/4]

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

square lattice graph copy constructor

◆ Square() [4/4]

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

square lattice graph move constructor

Member Function Documentation

◆ _checkpair()

template<typename FloatType >
void openjij::graph::Square< FloatType >::_checkpair ( Index  idx1,
Index  idx2 
) const
inlineprivate

check if the pair has a valid connection

Parameters
idx1index1
idx2index2

References openjij::graph::json_parse(), and openjij::graph::Square< FloatType >::to_rc().

Referenced by openjij::graph::Square< FloatType >::Square().

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

◆ get_num_column()

template<typename FloatType >
std::size_t openjij::graph::Square< FloatType >::get_num_column ( ) const
inline

get number of columns

Returns
number of columns

References openjij::graph::Square< FloatType >::_num_column.

◆ get_num_row()

template<typename FloatType >
std::size_t openjij::graph::Square< FloatType >::get_num_row ( ) const
inline

get number of rows

Returns
number of rows

References openjij::graph::Square< FloatType >::_num_row.

◆ h() [1/2]

template<typename FloatType >
FloatType & openjij::graph::Square< FloatType >::h ( std::size_t  r,
std::size_t  c 
)
inline

access h(row, colum) (local field)

Parameters
rrow index
ccolumn index
Returns
corresponding interaction value

References openjij::graph::Square< FloatType >::_num_column, openjij::graph::Square< FloatType >::_num_row, openjij::graph::Sparse< FloatType >::h(), openjij::graph::json_parse(), and openjij::graph::Square< FloatType >::to_ind().

Referenced by openjij::declare_Square().

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

◆ h() [2/2]

template<typename FloatType >
const FloatType & openjij::graph::Square< FloatType >::h ( std::size_t  r,
std::size_t  c 
) const
inline

access h(row, colum) (local field)

Parameters
rrow index
ccolumn index
Returns
corresponding interaction value

References openjij::graph::Square< FloatType >::_num_column, openjij::graph::Square< FloatType >::_num_row, openjij::graph::Sparse< FloatType >::h(), openjij::graph::json_parse(), and openjij::graph::Square< FloatType >::to_ind().

Here is the call graph for this function:

◆ J() [1/2]

template<typename FloatType >
FloatType & openjij::graph::Square< FloatType >::J ( std::size_t  r,
std::size_t  c,
Dir  dir 
)
inline

access J(row, colum, direction)

Parameters
rrow index
ccolumn index
dirdirection
Returns
corresponding interaction value

References openjij::graph::Square< FloatType >::_init_val, openjij::graph::Square< FloatType >::_num_column, openjij::graph::Square< FloatType >::_num_row, openjij::graph::Sparse< FloatType >::J(), openjij::graph::json_parse(), openjij::graph::MINUS_C, openjij::graph::MINUS_R, openjij::graph::PLUS_C, openjij::graph::PLUS_R, and openjij::graph::Square< FloatType >::to_ind().

Referenced by openjij::declare_Square().

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

◆ J() [2/2]

template<typename FloatType >
const FloatType & openjij::graph::Square< FloatType >::J ( std::size_t  r,
std::size_t  c,
Dir  dir 
) const
inline

◆ mod_c()

template<typename FloatType >
std::size_t openjij::graph::Square< FloatType >::mod_c ( std::int64_t  a) const
inlineprivate

mod function (a mod num_column)

Parameters
aparameter ([-1:num_column])
Returns
(a mod num_column)

References openjij::graph::Square< FloatType >::_num_column.

Referenced by openjij::graph::Square< FloatType >::to_ind().

Here is the caller graph for this function:

◆ mod_r()

template<typename FloatType >
std::size_t openjij::graph::Square< FloatType >::mod_r ( std::int64_t  a) const
inlineprivate

mod function (a mod num_row)

Parameters
aparameter ([-1:num_row])
Returns
(a mod num_row)

References openjij::graph::Square< FloatType >::_num_row.

Referenced by openjij::graph::Square< FloatType >::to_ind().

Here is the caller graph for this function:

◆ spin() [1/2]

template<typename FloatType >
const Spin & openjij::graph::Square< FloatType >::spin ( const Spins spins,
std::size_t  r,
std::size_t  c 
) const
inline

derive spin value at the index (row x column)

Parameters
spinsspin array
rrow index
ccolumn index
Returns
corresponding spin

References openjij::graph::json_parse(), and openjij::graph::Square< FloatType >::to_ind().

Here is the call graph for this function:

◆ spin() [2/2]

template<typename FloatType >
Spin & openjij::graph::Square< FloatType >::spin ( Spins spins,
std::size_t  r,
std::size_t  c 
) const
inline

derive spin value at the index (row x column)

Parameters
spinsspin array
rrow index
ccolumn index
Returns
corresponding spin

References openjij::graph::json_parse(), and openjij::graph::Square< FloatType >::to_ind().

Here is the call graph for this function:

◆ to_ind()

◆ to_rc()

template<typename FloatType >
RowColumn openjij::graph::Square< FloatType >::to_rc ( Index  ind) const
inline

convert from global index to (row x column) index

Parameters
indglobal index
Returns
corresponding (row x column) index (RowColumn type)

References openjij::graph::Square< FloatType >::_num_column, openjij::graph::Graph::get_num_spins(), and openjij::graph::json_parse().

Referenced by openjij::graph::Square< FloatType >::_checkpair().

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

Member Data Documentation

◆ _init_val

◆ _num_column

◆ _num_row


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