CommonLibrary  0.9.0
SquareMatrix< T > 構造体テンプレート

正方行列クラス [詳解]

SquareMatrix< T > の継承関係図
Matrix< T >

公開型

typedef T value_type
 要素の型
 
typedef Matrix< T >::iterator iterator
 反復子の型
 
typedef Matrix< T >::const_iterator const_iterator
 定数反復子の型
 
typedef Matrix< T >::size_type size_type
 添字の型
 

公開メンバ関数

 SquareMatrix ()
 デフォルト・コンストラクタ [詳解]
 
 SquareMatrix (size_type size, value_type val=value_type())
 行・列数を指定して構築 [詳解]
 
template<class In >
 SquareMatrix (In s, In e, size_type sz, bool inRows=true)
 データ列を指定して構築 [詳解]
 
template<class U >
 SquareMatrix (const SquareMatrix< U > &mat)
 行列の要素をコピーして構築 [詳解]
 
template<class U >
 SquareMatrix (const SymmetricMatrix< U > &mat)
 行列の要素をコピーして構築 [詳解]
 
template<class U >
SquareMatrixoperator= (const SquareMatrix< U > &mat)
 代入演算子の多重定義 [詳解]
 
template<class U >
SquareMatrixoperator= (const SymmetricMatrix< U > &mat)
 代入演算子の多重定義 [詳解]
 
size_type size () const
 行列のサイズを返す [詳解]
 
size_type rows () const
 行数を返す [詳解]
 
size_type cols () const
 列数を返す [詳解]
 
void resize (size_type size, value_type val=value_type())
 要素数 ( 行数 × 列数 ) を変更する [詳解]
 
void assign (size_type size, value_type val=value_type())
 要素数 ( 行数 × 列数 ) を変更し、値を初期化する [詳解]
 
template<class In >
void assign (In s, In e, size_type sz, bool inRows)
 データ列を指定して行列を初期化する [詳解]
 
iterator operator[] (size_type r)
 指定した行番号の反復子を返す(添字演算子) [詳解]
 
const_iterator operator[] (size_type r) const
 指定した行番号の定数反復子を返す(添字演算子) [詳解]
 
iterator row (size_type r, size_type start=0, size_type stride=1)
 指定した行番号の反復子を返す [詳解]
 
const_iterator row (size_type r, size_type start=0, size_type stride=1) const
 指定した行番号の定数反復子を返す [詳解]
 
iterator cbegin (size_type c)
 指定した列番号の反復子を返す [詳解]
 
const_iterator cbegin (size_type c) const
 指定した列番号の定数反復子を返す [詳解]
 
iterator column (size_type c, size_type start=0, size_type stride=1)
 指定した列番号の反復子を返す [詳解]
 
const_iterator column (size_type c, size_type start=0, size_type stride=1) const
 指定した列番号の定数反復子を返す [詳解]
 
iterator begin ()
 先頭位置から始まる全要素へアクセス可能な反復子を返す [詳解]
 
const_iterator begin () const
 先頭位置から始まる全要素へアクセス可能な定数反復子を返す [詳解]
 
iterator end ()
 要素の末尾を表す反復子を返す [詳解]
 
const_iterator end () const
 要素の末尾を表す定数反復子を返す [詳解]
 
void transpose ()
 要素の転置を行う [詳解]
 
void clone (SquareMatrix< T > *sqMat) const
 行列を複製する [詳解]
 
template<class U >
void clone (Matrix< U > *mat) const
 一般行列として複製する [詳解]
 
template<typename U >
SquareMatrix< T > & operator*= (const SquareMatrix< U > &mat)
 行列と掛け合わせる [詳解]
 

その他の継承メンバ

- 基底クラス Matrix< T > に属する継承非公開型
typedef T value_type
 要素の型
 
typedef indexer_iterator< std::valarray< T >, SliceIndexeriterator
 反復子の型
 
typedef const_indexer_iterator< std::valarray< T >, SliceIndexerconst_iterator
 定数反復子の型
 
typedef size_t size_type
 添字の型
 
- 基底クラス Matrix< T > に属する継承非公開メンバ関数
 Matrix ()
 デフォルト・コンストラクタ [詳解]
 
 Matrix (size_type rows, size_type cols, value_type val=value_type())
 行・列数を指定して構築 [詳解]
 
template<class In >
 Matrix (In s, In e, size_type sz, bool inRows)
 データ列を指定して構築 [詳解]
 
template<class U >
 Matrix (const Matrix< U > &mat)
 行列の要素をコピーして構築 [詳解]
 
template<class U >
 Matrix (const SquareMatrix< U > &mat)
 行列の要素をコピーして構築 [詳解]
 
template<class U >
 Matrix (const SymmetricMatrix< U > &mat)
 行列の要素をコピーして構築 [詳解]
 
template<class U >
Matrixoperator= (const Matrix< U > &mat)
 代入演算子の多重定義 [詳解]
 
template<class U >
Matrixoperator= (const SquareMatrix< U > &mat)
 代入演算子の多重定義 [詳解]
 
template<class U >
Matrixoperator= (const SymmetricMatrix< U > &mat)
 代入演算子の多重定義 [詳解]
 
void clone (Matrix< T > *mat) const
 行列を複製する [詳解]
 
void resize (size_type rows, size_type cols, value_type val=value_type())
 要素数 ( 行数 × 列数 ) を変更する [詳解]
 
void assign (size_type rows, size_type cols, value_type val=value_type())
 要素数 ( 行数 × 列数 ) を変更し、値を初期化する [詳解]
 
template<class In >
void assign (In s, In e, size_type sz, bool inRows)
 行列をデータ列で初期化する [詳解]
 
size_type rows () const
 行数を返す [詳解]
 
size_type cols () const
 列数を返す [詳解]
 
iterator operator[] (size_type r)
 指定した行番号の反復子を返す(添字演算子) [詳解]
 
const_iterator operator[] (size_type r) const
 指定した行番号の定数反復子を返す(添字演算子) [詳解]
 
iterator row (size_type r, size_type start=0, size_type stride=1)
 指定した行番号の反復子を返す [詳解]
 
const_iterator row (size_type r, size_type start=0, size_type stride=1) const
 指定した行番号の定数反復子を返す [詳解]
 
iterator cbegin (size_type c)
 指定した列番号の反復子を返す [詳解]
 
const_iterator cbegin (size_type c) const
 指定した列番号の定数反復子を返す [詳解]
 
iterator column (size_type c, size_type start=0, size_type stride=1)
 指定した列番号の反復子を返す [詳解]
 
const_iterator column (size_type c, size_type start=0, size_type stride=1) const
 指定した列番号の定数反復子を返す [詳解]
 
iterator begin ()
 先頭位置から始まる全要素へアクセス可能な反復子を返す [詳解]
 
const_iterator begin () const
 先頭位置から始まる全要素へアクセス可能な定数反復子を返す [詳解]
 
iterator end ()
 要素の末尾を表す反復子を返す [詳解]
 
const_iterator end () const
 要素の末尾を表す定数反復子を返す [詳解]
 
void transpose ()
 要素の転置を行う [詳解]
 

詳解

template<typename T>
struct SquareMatrix< T >

正方行列クラス

構築子と解体子

◆ SquareMatrix() [1/5]

template<typename T>
SquareMatrix< T >::SquareMatrix ( )
inline

デフォルト・コンストラクタ

行列数はゼロで初期化する。

◆ SquareMatrix() [2/5]

template<typename T>
SquareMatrix< T >::SquareMatrix ( size_type  size,
value_type  val = value_type() 
)
inlineexplicit

行・列数を指定して構築

要素は初期値 val で初期化される。val のデフォルトは value_type のデフォルト値になる。

引数
size行・列数
val初期値

◆ SquareMatrix() [3/5]

template<typename T>
template<class In >
SquareMatrix< T >::SquareMatrix ( In  s,
In  e,
size_type  sz,
bool  inRows = true 
)
inline

データ列を指定して構築

データが不足した場合、残りの要素は value_type のデフォルト値となる。

引数
sデータ列の開始位置
eデータ列の末尾の次の位置
sz行(または列)のサイズ
inRowstrueなら行方向に、falseなら列方向にデータ列を並べる

◆ SquareMatrix() [4/5]

template<typename T>
template<class U >
SquareMatrix< T >::SquareMatrix ( const SquareMatrix< U > &  mat)
inline

行列の要素をコピーして構築

引数
matコピー元の正方行列

◆ SquareMatrix() [5/5]

template<class T >
template<class U >
SquareMatrix< T >::SquareMatrix ( const SymmetricMatrix< U > &  mat)

行列の要素をコピーして構築

引数
matコピー元の対称行列

関数詳解

◆ operator=() [1/2]

template<typename T>
template<class U >
SquareMatrix& SquareMatrix< T >::operator= ( const SquareMatrix< U > &  mat)
inline

代入演算子の多重定義

引数
mat代入元の正方行列

◆ operator=() [2/2]

template<typename T>
template<class U >
SquareMatrix& SquareMatrix< T >::operator= ( const SymmetricMatrix< U > &  mat)

代入演算子の多重定義

引数
mat代入元の対称行列

◆ size()

template<typename T>
size_type SquareMatrix< T >::size ( ) const
inline

行列のサイズを返す

戻り値
行列のサイズ

◆ rows()

template<typename T>
size_type SquareMatrix< T >::rows ( ) const
inline

行数を返す

Matrix との互換性のためにあるが、SquareMatrix< T >::size() と内容は同じである。

戻り値
行数

◆ cols()

template<typename T>
size_type SquareMatrix< T >::cols ( ) const
inline

列数を返す

Matrix との互換性のためにあるが、SquareMatrix< T >::size() と内容は同じである。

戻り値
列数

◆ resize()

template<typename T>
void SquareMatrix< T >::resize ( size_type  size,
value_type  val = value_type() 
)
inline

要素数 ( 行数 × 列数 ) を変更する

行・列それぞれの方向に対し、サイズが小さくなる場合は末尾側の要素は削除され、大きくなる場合は 増分が初期値 val で埋められる。

引数
size行・列数
val増分に対する初期値
戻り値
なし

◆ assign() [1/2]

template<typename T>
void SquareMatrix< T >::assign ( size_type  size,
value_type  val = value_type() 
)
inline

要素数 ( 行数 × 列数 ) を変更し、値を初期化する

引数
size行・列数
val初期化する値
戻り値
なし

◆ assign() [2/2]

template<class T >
template<class In >
void SquareMatrix< T >::assign ( In  s,
In  e,
size_type  sz,
bool  inRows 
)

データ列を指定して行列を初期化する

データが不足した場合、残りの要素は value_type のデフォルト値となる。 sz がゼロの場合、ExceptionNotPositiveNumber 例外を投げる。また、データ列 [ s, e ) の指定が不正だった場合、 ExceptionNegativeLength 例外を投げる。

引数
sデータ列の開始位置
eデータ列の末尾の次の位置
sz行(または列)のサイズ
inRowstrueなら行方向に、falseなら列方向にデータ列を並べる

◆ operator[]() [1/2]

template<typename T>
iterator SquareMatrix< T >::operator[] ( size_type  r)
inline

指定した行番号の反復子を返す(添字演算子)

引数
r行番号
戻り値
行の反復子

◆ operator[]() [2/2]

template<typename T>
const_iterator SquareMatrix< T >::operator[] ( size_type  r) const
inline

指定した行番号の定数反復子を返す(添字演算子)

引数
r行番号
戻り値
行の定数反復子

◆ row() [1/2]

template<typename T>
iterator SquareMatrix< T >::row ( size_type  r,
size_type  start = 0,
size_type  stride = 1 
)
inline

指定した行番号の反復子を返す

範囲外の行番号を指定した場合は out_of_range 例外を投げる。 また、列方向の飛び幅がゼロの場合、ExceptionNotPositiveNumber 例外を投げる。

引数
r行番号
start列番号の開始位置
stride列方向の飛び幅
戻り値
行の反復子

◆ row() [2/2]

template<typename T>
const_iterator SquareMatrix< T >::row ( size_type  r,
size_type  start = 0,
size_type  stride = 1 
) const
inline

指定した行番号の定数反復子を返す

範囲外の行番号を指定した場合は out_of_range 例外を投げる。 また、列方向の飛び幅がゼロの場合、ExceptionNotPositiveNumber 例外を投げる。

引数
r行番号
start列番号の開始位置
stride列方向の飛び幅
戻り値
行の定数反復子

◆ cbegin() [1/2]

template<typename T>
iterator SquareMatrix< T >::cbegin ( size_type  c)
inline

指定した列番号の反復子を返す

覚え書き
添字に対するチェックは行わない。
引数
c列番号
戻り値
列の反復子

◆ cbegin() [2/2]

template<typename T>
const_iterator SquareMatrix< T >::cbegin ( size_type  c) const
inline

指定した列番号の定数反復子を返す

覚え書き
添字に対するチェックは行わない。
引数
c列番号
戻り値
列の定数反復子

◆ column() [1/2]

template<typename T>
iterator SquareMatrix< T >::column ( size_type  c,
size_type  start = 0,
size_type  stride = 1 
)
inline

指定した列番号の反復子を返す

範囲外の列番号を指定した場合は out_of_range 例外を投げる。 また、行方向の飛び幅がゼロの場合、ExceptionNotPositiveNumber 例外を投げる。

引数
c列番号
start行番号の開始位置
stride行方向の飛び幅
戻り値
列の反復子

◆ column() [2/2]

template<typename T>
const_iterator SquareMatrix< T >::column ( size_type  c,
size_type  start = 0,
size_type  stride = 1 
) const
inline

指定した列番号の定数反復子を返す

範囲外の列番号を指定した場合は out_of_range 例外を投げる。 また、行方向の飛び幅がゼロの場合、ExceptionNotPositiveNumber 例外を投げる。

引数
c列番号
start行番号の開始位置
stride行方向の飛び幅
戻り値
列の定数反復子

◆ begin() [1/2]

template<typename T>
iterator SquareMatrix< T >::begin ( )
inline

先頭位置から始まる全要素へアクセス可能な反復子を返す

先頭から行方向へたどり、末尾に達したら次の列の先頭に移る。

戻り値
対象の反復子

◆ begin() [2/2]

template<typename T>
const_iterator SquareMatrix< T >::begin ( ) const
inline

先頭位置から始まる全要素へアクセス可能な定数反復子を返す

先頭から行方向へたどり、末尾に達したら次の列の先頭に移る。

戻り値
対象の定数反復子

◆ end() [1/2]

template<typename T>
iterator SquareMatrix< T >::end ( )
inline

要素の末尾を表す反復子を返す

戻り値
末尾の反復子

◆ end() [2/2]

template<typename T>
const_iterator SquareMatrix< T >::end ( ) const
inline

要素の末尾を表す定数反復子を返す

戻り値
末尾の定数反復子

◆ transpose()

template<class T >
void SquareMatrix< T >::transpose ( )

要素の転置を行う

戻り値
なし

◆ clone() [1/2]

template<typename T>
void SquareMatrix< T >::clone ( SquareMatrix< T > *  sqMat) const
inline

行列を複製する

todo:
型を任意とすべきか ?
引数
sqMat複製先の行列

◆ clone() [2/2]

template<class T >
template<class U >
void SquareMatrix< T >::clone ( Matrix< U > *  mat) const

一般行列として複製する

引数
mat複製先の行列へのポインタ
戻り値
なし

◆ operator*=()

template<class T >
template<typename U >
SquareMatrix< T > & SquareMatrix< T >::operator*= ( const SquareMatrix< U > &  mat)

行列と掛け合わせる

サイズが、掛け合わせる行列のサイズと等しくないときは、ExceptionNotEqualNumber を投げる。

引数
mat対象行列への参照
戻り値
自分自身への参照

この構造体詳解は次のファイルから抽出されました: