プ ン引数
IMSL_EQUILIBRATE, int equilibrate (入力)
入力行列 A 因子分解 前に平衡させ に指定す equilibrate 説明
0 平衡化し い
1 平衡化す
フ : equilibrate = 0
IMSL_COLUMN_ORDERING_METHOD, Imsl_col_ordering method (入力)
分解 前に 疎 保 ようにす 列 並び え方法 次 一 method に設定し 並び え法 選択す
method 説明
IMSL_NATURAL 自然順序 す わ 入力行列 列順
IMSL_MMD_ATA ATA 構造体 最小次 順 IMSL_MMD_AT_PLUS_A AT + A 構造体 最小次 順
IMSL_COLAMD 列近似最小次 順
IMSL_PERMC プ ン引数 IMSL_COLPERM_VECTOR ー
が入力した置換ベク permc 与え 順 ベク permc 数 0,1,…,n-1 置換 す
フ : method = IMSL_COLAMD
IMSL_COLPERM_VECTOR, int permc[] (入力)
後並び え(postordering) 前 置換行列 P 定義す 長さ n 配列 こ 引数
IMSL_COLUMN_ORDERING_METHOD が method = IMSL_PERMC 用い 必 須 あ そ 以外 無視さ
IMSL_TRANSPOSE, int transpose (入力)
転置 問題 ATx = b 解く場合に指定す こ プ ン 因子分解 指定す プ
ン 一緒に使うこ が
transpose 説明
0 Ax = b 解く
1 ATx = b 解く.
フ : transpose = 0
IMSL_ITERATIVE_REFINEMENT, int refine (入力) 反復改良 す う 指定す
refine 説明
0 反復改良 し い
1 反復改良 す
フ : refine = 1
IMSL_FACTOR_SOLVE, int factsol (入力)
LU 分解 け 線形方程式 解く け 両方行う 指定す factsol 説明
0 A LU 分解 方程式 Ax = b 解も求
1 LU 分解 け 行 う LU 分解 プ ン引数
IMSL_RETURN_SPARSE_LU_FACTOR 引 渡さ 入力引 数 b 無視さ
factsol 説明
2 与え たLU分解 Ax = b 解く LU分解 プ ン引
数IMSL_SUPPLY_SPARSE_LU_FACTOR 渡さ
い 入力引数 A 反復改良 条件数 計算 あ い ッ 増大因子 逆数 計算以外 無視さ
フ : factsol = 0
IMSL_DIAG_PIVOT_THRESH, double diag_pivot_thresh (入力) 対角項が ッ し 扱わ う 閾値 指定す 0.0
diag_pivot_thresh
1.0.フ : diag_pivot_thresh = 1.0
IMSL_SNODE_PREDICTION, int snode_prediction (入力)
L ーパー ー にあ 非 ロ 数 予測方法 示す
snode_prediction 説明
0 静的方法 使う
1 動的方法 使う
フ : snode_prediction = 0
IMSL_PERFORMANCE_TUNING, int sp_ienv[] (入力)
長さ 8 配列 ー が因子分解 ア 性能 チ ーニングす 際 正 パ ータ す
i sp_ienv[i] 説明
0 パネ イ
フ : sp_ienv[0] = 10
1 ーパー ー 融合 制御す 緩和パ ータ
フ : sp_ienv[1] = 5
2 ーパー ー 最大許容 イ
フ : sp_ienv[2] = 100
3 2D ロッキングに使わ 最小 行次元
フ : sp_ienv[3] = 200
4 2D ロッキングに使わ 最小 列次元
フ : sp_ienv[4] = 40
5 L ーパー ー 値 格納す 配列 nzval 大 さ 負 場合 充
填増加因子 す わ そ 大 さ 絶対値 元 行列A 非 ロ 数 積が格納領域 アロ ー す に用い ます 正 場合 保存領 域がアロ ー さ 非 ロ 数 表す
配列 sp_ienv こ 要素 L ーパー ー にあ 非 ロ 数 予測
が動的 方法 場合 す わ snode_prediction = 1 けに用い
フ : sp_ienv[5] = -20
6 列 U に格納す 配列 rowind nzval 大 さ 負 場合 充填 増加因子 す わ そ 大 さ 絶対値 元 行列A 非 ロ 数 積が格納領域 アロ ー す に用い ます 正 場合 格納領域 がアロ ー さ 非 ロ 数 表す
フ : sp_ienv[6] = -20
7 L ーパー ー 添え字 格納す 配列 rowind 大 さ 負 場合
充填増加因子 す わ そ 大 さ 絶対値 元 行列A 非 ロ 数 積が格納領域 アロ ー す に用い ます 正 場合 格 納領域がアロ ー さ 非 ロ 数 表す
フ : sp_ienv[7] = -10
IMSL_CSC_FORMAT, int HB_col_ptr[], int HB_row_ind[], float HB_values[] (入力)
縮さ た疎 列 ー (CSC) 係数行列 受け入 こ ー 説明 イン ロダ
ク ン 参照
IMSL_SUPPLY_SPARSE_LU_FACTOR, Imsl_f_super_lu_factor lu_factor_supplied (入力) プ ン IMSL_RETURN_SPARSE_LU_FACTOR 計算さ た入力行列 LU 分解 含
Imsl_f_super_lu_factor 型 構造体 こ 構造体に い 説明 参照 こ 構造体
内に割 当 た領域 解放す に 関数 imsl_f_superlu_factor_free 使う IMSL_RETURN_SPARSE_LU_FACTOR, Imsl_f_super_lu_smp_factor *lu_factor_returned (出力)
入力行列 LU 分解 含 Imsl_f_super_lu_smp_factor型 構造体 ア こ 構造体
に い 説明 参照 こ 構造体内に割 当 た領域 解放す に 関数 imsl_f_superlu_smp_factor_free 使う
IMSL_CONDITION, float *condition (出力) 平衡化 後 行列 条件数 逆数 推定
IMSL_PIVOT_GROWTH_FACTOR, float *recip_pivot_growth (出力) ッ 増大因子 逆数
min (j P D AD Pr r c c j) /Uj
recip_pivot_growth が 1 よ 非常に小さい場合 LU 分解 安定性 良く い IMSL_FORWARD_ERROR_BOUND, float *ferr (出力)
解ベク x に対す 推定さ 前方誤差範囲 こ プ ン 引数 IMSL_ITERATIVE_REFINEMENT 1 に設定す こ が必要 す IMSL_BACKWARD_ERROR, float *berr (出力)
解ベク x 成分毎 相対後方誤差 こ プ ン 引数 IMSL_ITERATIVE_REFINEMENT 1 に設定す こ が必要 す IMSL_RETURN_USER, float x[] (出力)
線形方程式 解 x 含 ー 割 当 長さ n 配列
説明
imsl_f_superlu_smp 線型方程式 解法 逐次版 imsl_f_superlu 同 す
関数 imsl_f_superlu_smp 行列 A LU分解 ーパー ーダ 格納方式 用います 逐次版 比 べ L LU 因子 連続す 列 ーパー ー 連続 いこ があ ます 従
各列あ い ーパー ー 始 インタ く 各列あ い ーパー ー 終わ インタも必要 ます 因子分解 構造体 Imsl_f_super_lu_smp_factor そ 構造体 Imsl_f_hbp_format Imsl_f_scp_format に含ま ます
こ 構造体 以下に記述します
表 1.1 構造体 Imsl_f_hbp_format
パ ータ ータ型 説明
nnz int 行列 非 ロ 数
nzval float * 列 パックさ た非 ロ値 配列
rowind int * 非 ロ 行番号 配列
colbeg int * 大 さ ncol+1 配列 colbeg[j] nzval[]
rowind[] に列 j が始ま 位置 格納す 要素
colbeg[ncol] 配列 nzval[] rowind[] 最初 フ ー 位置 指す
colend int * 大 さ ncol 配列 colend[j] nzval[]
rowind[] に列 j 最後 要素 一 先 位置 格納す
表 1.2 構造体 Imsl_f_scp_format
パ ータ ータ型 説明
nnz int ーパー ーダ 行列 非 ロ 数
nsuper int ーパー ー 数 1 引いたも
nzval float * 列 パックさ た非 ロ値 配列
nzval_colbeg int * 大 さ ncol+1 配列 nzval_colbeg[j] -nzval[]
列 j 始 指す ン nzval_colbeg[ncol]
nzval[] 最初 フ ー 位置 指す
nzval_colend int * 大 さ ncol 配列 nzval_colend[j] nzval[]
列 j 最後 要素 一 先 位置 指す
rowind int * 矩形 ーパー ー 縮さ た行イン ック 配列
rowind_colbeg int * 大 さ ncol+1 配列 rowind_colbeg[j] rowind[]
列 j 始 指す 要素 rowind_colbeg[ncol]
rowind[] 最初 フ ー 位置 指す
rowind_colend int * 大 さ ncol 配列 rowind_colend[j] rowind[]
列 j 最後 要素 一 先 位置 指す
col_to_sup int * 大 さ ncol+1 配列 col_to_sup[j] 列 j が所属す ーパー ー 番号 col_to_sup[] 最初 ncol 個 ン けが定義さ
sup_to_colbeg int * 大 さ ncol+1 配列 sup_to_colbeg[s] s 番目 ーパー ー 最初 列 指す こ 配列 最初 nsuper+1 位置 けが用い
sup_to_colend int * 大 さ ncol 配列 sup_to_colend[s] s 番目 ーパー ー 最後 列 一 先 指す こ 配列 最初 nsuper+1 位置 けが用い
表 1.3 構造体 Imsl_f_super_lu_smp_factor
パ ータ ータ型 説明
nrow int 行列 A 行数
ncol int 行列 A 列数
equilibration_
method int A 平衡化す 方法:
0 – 平衡化し い
1 – 行 平衡化
2 – 列 平衡化
3 – 行 列 平衡化
rowscale float * 大 さ nrow 配列 A に対す 行 ー 因子 含
columnscale float * 大 さ ncol 配列 A に対す 列 ー 因子 含
rowperm int * 大 さ nrow 行置換配列 行置換行列 Pr 表す
colperm int * 大 さ ncol 列置換配列 列置換行列 Pc 表す
U Imsl_f_hbp
_format * ーパー ーダ ロック 外 A U 因子 部分
Harwell-Boeing フ ー ッ 格納さ
L Imsl_f_scp
_format * A L 因子 ロック下 角行列 し ーパー ーダ
フ ー ッ 格納さ
構造体 Imsl_d_super_lu_smp_factor そ 構造体も同様にそ 定義 float double に
Imsl_f_hbp_format Imsl_d_hbp_format に Imsl_f_scp_format Imsl_d_scp_format に置 換えたも す
逐次版 比べ LU 分解 こ が並列処理さ ます 逐次版 よう 動的 拡大 並列コー
に実装す 困難 ー が L 配列 rowind U 配列 rowind nzval ( 表 構造
体 Imsl_f_scp_format Imsl_f_hbp_format 参照) 大 さ 推定値 性能チ ーニング配列 sp_ienv
要素 6 7 提供せ ませ
L ーパー ー 各々が連続した に格納さ ようにす た に L ーパー ー 大 さに い 静的あ い 動的 予測 す こ が ます 静的バージ ン 関数 imsl_f_superlu_smp
が フ 使う方法 すが PA = LU 行置換 P に対し L 非 ロ構造 Householder パー
QR 分解 A = QR Householder行列 H 非 ロ構造に含ま い こ 使います さ に L 基
本 ーパー ー 各々 常に H 基本 ーパー ー に含ま い こ 示すこ が ます 従
L ーパー ー L 因子 配列 nzval H ーパー ー 大 さに基 い 分解 前に推
定 アロ ー す こ が ます ーパー ー 分割 H ーパー ー 大 さ 計算量 行列 A 非 ロ 数にほ 線型 す
実際に 静的予測方法 多く 問題 十分 あ ませ し し H 非 ロ 数が L 非 ロ 数よ 大 い場合 プ ン引数 IMSL_SNODE_PREDICTION 1 に ッ し 動的 予測 試 こ が ます こ 方法 も H ーパー ー 分割 使いますが L ーパー ー ダ グ フ 動的に探査し 要求さ ー よ 厳密 限 得 こ が ます 動的方法 使 うに ー 性能チ ーニング配列 sp_ienv 要素 5 L 因子 配列 nzval 大 さ 決
ませ
並列 ア 詳細 Demmel et al. (1999c) 参照
Copyright (c) 2003, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from U.S. Dept. of Energy)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
(1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
(2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
(3) Neither the name of Lawrence Berkeley National Laboratory, U.S. Dept. of Energy nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
例題 1
疎 6×6 行列
LU 分解 します
y = (1,2,3,4,5,6)T す b1 := Ay = (10,7,45,33,-34,31)T b2 := ATy = (-9,8,39,13,1,21)T A LU 分解 疎 線型方程式 Ax = b1 よび ATx = b2 解く に用い ます
#include <imsl.h>
int main(){
Imsl_f_sparse_elem a[] = { 0, 0, 10.0, 1, 1, 10.0,
1, 2, -3.0, 1, 3, -1.0, 2, 2, 15.0, 3, 0, -2.0, 3, 3, 10.0, 3, 4, -1.0, 4, 0, -1.0, 4, 3, -5.0, 4, 4, 1.0, 4, 5, -3.0, 5, 0, -1.0, 5, 1, -2.0, 5, 5, 6.0};
float b1[] = {10.0, 7.0, 45.0, 33.0, -34.0, 31.0};
float b2[] = { -9.0, 8.0, 39.0, 13.0, 1.0, 21.0 };
int n = 6, nz = 15;
float *x = NULL;
x = imsl_f_superlu_smp (n, nz, a, b1, 0);
imsl_f_write_matrix ("solution to A*x = b1", 1, n, x, 0);
imsl_free (x);
x = imsl_f_superlu_smp (n, nz, a, b2, IMSL_TRANSPOSE, 1, 0);
imsl_f_write_matrix ("solution to A^T*x = b2", 1, n, x, 0);
imsl_free (x);
}
出力
solution to A*x = b1
1 2 3 4 5 6 1 2 3 4 5 6 solution to A^T*x = b2
1 2 3 4 5 6 1 2 3 4 5 6
例題 2
ここ 行列 A = E(1000,10) 用い LU 分解が異 右辺 持 線型方程式 解く に用い
こ 示します 最大絶対誤差 プ ン します 計算 後 LU 分解 た にアロ ー さ た 領域 関数 imsl_f_superlu_smp_factor_free 解放します
#include <imsl.h>
#include <stdlib.h>
#include <stdio.h>
int main(){
Imsl_f_sparse_elem *a = NULL;
Imsl_f_super_lu_smp_factor lu_factor;
float *b = NULL, *x = NULL, *mod_five = NULL, *mod_ten = NULL;
float error_factor_solve, error_solve;
int n = 1000, c = 10;
int i, nz, index;
/* Get the coefficient matrix */
a = imsl_f_generate_test_coordinate (n, c, &nz, 0);
/* Set two different predetermined solutions */
mod_five = (float*) malloc (n*sizeof(*mod_five));
mod_ten = (float*) malloc (n*sizeof(*mod_ten));
for (i=0; i<n; i++) {
mod_five[i] = (float) (i % 5);
mod_ten[i] = (float) (i % 10);
}
/* Choose b so that x will approximate mod_five */
b = (float *) imsl_f_mat_mul_rect_coordinate ("A*x", IMSL_A_MATRIX, n, n, nz, a,
IMSL_X_VECTOR, n, mod_five, 0);
/* Solve Ax = b */
x = imsl_f_superlu_smp (n, nz, a, b,
IMSL_RETURN_SPARSE_LU_FACTOR, &lu_factor, 0);
/* Compute max absolute error */
error_factor_solve = imsl_f_vector_norm (n, x, IMSL_SECOND_VECTOR, mod_five,
IMSL_INF_NORM, &index, 0);
free (mod_five);
imsl_free (b);
imsl_free (x);
/* Get new right hand side -- b = A * mod_ten */
b = (float *) imsl_f_mat_mul_rect_coordinate ("A*x", IMSL_A_MATRIX, n, n, nz, a,
IMSL_X_VECTOR, n, mod_ten, 0);
/* Use the previously computed factorization to solve Ax = b */
x = imsl_f_superlu_smp (n, nz, a, b,
IMSL_SUPPLY_SPARSE_LU_FACTOR, &lu_factor, IMSL_FACTOR_SOLVE, 2,
0);
error_solve = imsl_f_vector_norm (n, x, IMSL_SECOND_VECTOR, mod_ten,
IMSL_INF_NORM, &index, 0);
free (mod_ten);
imsl_free (b);
imsl_free (x);
imsl_free (a);
/* Free sparse LU structure */
imsl_f_superlu_smp_factor_free (&lu_factor);
/* Print errors */
printf ("absolute error (factor/solve) = %e\n", error_factor_solve);
printf ("absolute error (solve) = %e\n", error_solve);
}
出力
absolute error (factor/solve) = 1.096725e-005 absolute error (solve) = 5.435944e-005
警告 ー
IMSL_ILL_CONDITIONED 入力行列 非常に悪条件 あ そ L1 条件数 逆
数 推定値 “rcond” = # あ 解 正確 い もし い
重大 ー
IMSL_SINGULAR_MATRIX 入力行列 特異 あ
superlu_smp 複素数
左方コ 法 一般複素疎行列 LU 分解 OpenMP並列 行 い 複素数 疎 線形方程式 Ax = b 解 ます
梗概
#include <imsl.h>
f_complex *imsl_c_superlu_smp (int n, int nz, Imsl_c_sparse_elem a[], f_complex b[],…,0) void imsl_c_superlu_smp_factor_free (Imsl_c_super_lu_smp_factor *factor)
d_complex 型 関数 imsl_z_superlu_smp imsl_z_superlu_smp_factor_free
必須 引数
int n (入力)
入力行列 次数 int nz (入力)
行列 非 ロ 数 Imsl_c_sparse_elem a[] (入力)
長さ nz 配列 行列 非 ロ ン 位置 値 含 Imsl_c_sparse_elem構造体
説明 本 ニ ア イン ロダク ン 参照し 下さい f_complex b[] (入力)
右辺 含 長さ n 配列
戻 値
疎 線形方程式 Ax = b 解 x へ インタ こ 領域 解放す に imsl_free 使う
解が得 い場合 NULL が返さ ます
プ ン引数 梗概
#include <imsl.h>
f_complex *imsl_c_superlu_smp
(int
n, int
nz, Imsl_c_sparse_elem
a[], f_complex
b[],
IMSL_EQUILIBRATE, int
equilibrate,
IMSL_COLUMN_ORDERING_METHOD
, Imsl_col_ordering
method,
IMSL_COLPERM_VECTOR, int
permc[],
IMSL_TRANSPOSE
, int
transpose,
IMSL_ITERATIVE_REFINEMENT
, int
refine,
IMSL_FACTOR_SOLVE, int
factsol,
IMSL_DIAG_PIVOT_THRESH
, float
diag_pivot_thresh,
IMSL_SNODE_PREDICTION, int
snode_prediction,
IMSL_PERFORMANCE_TUNING, int
sp_ienv[],
IMSL_CSC_FORMAT
, int
HB_col_ptr[], int
HB_row_ind[], f_complex
HB_values[],
IMSL_SUPPLY_SPARSE_LU_FACTOR,
Imsl_c_super_lu_smp_factor *lu_factor_supplied
,
IMSL_RETURN_SPARSE_LU_FACTOR,
Imsl_c_super_lu_smp_factor *lu_factor_returned, IMSL_CONDITION
, float
*condition,
IMSL_PIVOT_GROWTH_FACTOR
, float
*recip_pivot_growth, IMSL_FORWARD_ERROR_BOUND, float
*ferr,
IMSL_BACKWARD_ERROR
, float
*berr,
IMSL_RETURN_USER, f_complex
x[],
0)
プ ン引数
IMSL_EQUILIBRATE, int equilibrate (入力)
入力行列 A 因子分解 前に平衡させ に指定す equilibrate 説明
0 平衡化し い
1 平衡化す
フ : equilibrate = 0
IMSL_COLUMN_ORDERING_METHOD, Imsl_col_ordering method (入力)
分解 前に 疎 保 ようにす 列 並び え方法 次 一 method に設定し 並び え法 選択す
method 説明
IMSL_NATURAL 自然順序 す わ 入力行列 列順
IMSL_MMD_ATA ATA 構造体 最小次 順 IMSL_MMD_AT_PLUS_A AT + A 構造体 最小次 順
IMSL_COLAMD 列近似最小次 順
IMSL_PERMC プ ン引数 IMSL_COLPERM_VECTOR ー が入力した置換ベク permc 与え
順 ベク permc 数 0,1,…,n-1 置換 す
フ : method = IMSL_COLAMD
IMSL_COLPERM_VECTOR, int permc[] (入力)
後並び え(postordering) 前 置換行列 P 定義す 長さ n 配列 こ 引数
IMSL_COLUMN_ORDERING_METHOD が method = IMSL_PERMC 用い 必 須 あ そ 以外 無視さ
IMSL_TRANSPOSE, int transpose (入力)
転置 問題 ATx = b あ い AHx = b 解く場合に指定す こ プ ン 因子分解
指定す プ ン 一緒に使うこ が transpose 説明
0 Ax = b 解く
1 ATx = b 解く. 2 AHx = b 解く.
フ : transpose = 0
IMSL_ITERATIVE_REFINEMENT, int refine (入力) 反復改良 す う 指定す
refine 説明
0 反復改良 し い
1 反復改良 す
フ : refine = 1