|
|
◆ ZHBWrite1()
| Sub ZHBWrite1 |
( |
Fname As |
String, |
|
|
ByVal Title As |
String, |
|
|
Key As |
String, |
|
|
Nrow As |
Long, |
|
|
Ncol As |
Long, |
|
|
Nnz As |
Long, |
|
|
Val() As |
Complex, |
|
|
Ptr() As |
Long, |
|
|
Ind() As |
Long, |
|
|
DataType As |
Long, |
|
|
MatShape As |
Long, |
|
|
MatForm As |
Long, |
|
|
Optional Info As |
Long, |
|
|
Optional Fchk As |
Long = 0, |
|
|
Optional Base As |
Long = -1, |
|
|
Optional Format As |
Long = 0 |
|
) |
| |
Write a matrix to the Harwell-Boeing file (Complex matrix) (Simple driver)
- Purpose
- This routine writes a sparse matrix (CSR, CSC oe COO format) to the Harwell-Boeing file.
The data is written as it is without checking the contents such as the order.
RHS (including initial guess and exact solution) will not be written.
- Parameters
-
| [in] | Fname | Output file name. |
| [in] | Title | Title string. |
| [in] | Key | Key string. |
| [in] | Nrow | Number of rows of the matrix. (Nrow >= 0) (If Nrow = 0, returns without computation) |
| [in] | Ncol | Number of columns of the matrix. (Ncol >= 0) (If Ncol = 0, returns without computation) |
| [in] | Nnz | Number of non-zero elements. (= Ptr(Nrow) - Ptr(0) (CSR) or Ptr(Ncol) - Ptr(0) (CSC)) (Nnz >= 0) (If Nnz = 0, returns without computation) |
| [in] | Val() | Array Val(LVal - 1) (LInd >= Nnz)
Nonzero elements of sparse matrix. |
| [in] | Ptr() | Array Ptr(LPtr - 1) (LPtr >= Nrow + 1 (CSR), LPtr >= Ncol + 1 (CSC) or LPtr >= Nnz (COO))
Row pointers (if CSR), column pointers (if CSC), or row indices (if COO). |
| [in] | Ind() | Array Ind(LInd - 1) (LInd >= Nnz)
Column indices (if CSR or COO) or row indices (if CSC). |
| [in] | DataType | Data type of the matrix.
= 1: Complex.
= 2: Pattern. |
| [in] | MatShape | Matrix shape.
= 0: Unsymmetric.
= 1: Symmetric.
= 2: Skew-symmetric.
= 3: Hermitian.
= 4: Rectangular. |
| [in] | MatForm | Storage format of the matrix.
= 0: Sparse matrix. |
| [out] | Info | (Optional)
= 0: Successful exit.
= i < 0: The (-i)-th argument is invalid.
= 1: Failed to open file.
= 2: File already exists.
= 5: Memory error. |
| [in] | Fchk | (Optional)
Flag to check if output file exists. (default = 0)
= 0: Overwrite without checking if the specified file already exists.
= 1: Return as error (Info = 2) if the specified file already exists. |
| [in] | Base | (Optional)
Index style of Ptr and Ind. (default = Ptr(0))
= 0: Zero-based (C style) indexing: Starting index is 0.
= 1: One-based (Fortran style) indexing: Starting index is 1. |
| [in] | Format | (Optional)
Sparse matrix format. (default = 0)
= 0: CSR format.
= 1: CSC format.
= 2: COO format. |
- Example Program
- Writes the following matrix to the file (Test_ZHBWrite1.cua) in Harwell-Boeing format.
( 0.78+0.16i -0.9-1.46i 0.48-1.08i )
A = ( 0.73+0.63i 1.58-1.24 -0.41-0.91i )
( 0.23-1.37i 0.79+0.64i -0.73-1.5i )
Sub Ex_ZHBWrite1()
Const M = 3, N = 3, Nnz = M * N
Const DataType = 1, MatShape = 0, MatForm = 0
Dim A(Nnz - 1) As Complex, Ia(M) As Long, Ja(Nnz - 1) As Long
Dim Info As Long
A(0) = Cmplx(0.78, 0.16): A(1) = Cmplx(-0.9, -1.46): A(2) = Cmplx(0.48, -1.08): A(3) = Cmplx(0.73, 0.63): A(4) = Cmplx(1.58, -1.24): A(5) = Cmplx(-0.41, -0.91): A(6) = Cmplx(0.23, -1.37): A(7) = Cmplx(0.79, 0.64): A(8) = Cmplx(-0.73, -1.5)
Ia(0) = 0: Ia(1) = 3: Ia(2) = 6: Ia(3) = 9
Ja(0) = 0: Ja(1) = 1: Ja(2) = 2: Ja(3) = 0: Ja(4) = 1: Ja(5) = 2: Ja(6) = 0: Ja(7) = 1: Ja(8) = 2
Call ZHBWrite1("Test_ZHBWrite1.cua", Title, Key, M, N, Nnz, A(), Ia(), Ja(), DataType, MatShape, MatForm, Info)
End Sub
Function Cmplx(R As Double, Optional I As Double=0) As Complex Building complex number
Sub ZHBWrite1(Fname As String, ByVal Title As String, Key As String, Nrow As Long, Ncol As Long, Nnz As Long, Val() As Complex, Ptr() As Long, Ind() As Long, DataType As Long, MatShape As Long, MatForm As Long, Optional Info As Long, Optional Fchk As Long=0, Optional Base As Long=-1, Optional Format As Long=0) Write a matrix to the Harwell-Boeing file (Complex matrix) (Simple driver)
- Example Results
- Example Results (Test_ZHBWrite1.cua file)
9 1 2 6 0
CUA 3 3 9 0
(8I10) (8I10) (3D23.15) (3D23.15)
1 4 7 10
1 2 3 1 2 3 1 2
3
7.800000000000000e-01 1.600000000000000e-01 7.300000000000000e-01
6.300000000000000e-01 2.300000000000000e-01 -1.370000000000000e+00
-9.000000000000000e-01 -1.460000000000000e+00 1.580000000000000e+00
-1.240000000000000e+00 7.900000000000000e-01 6.400000000000000e-01
4.800000000000000e-01 -1.080000000000000e+00 -4.100000000000000e-01
-9.100000000000000e-01 -7.300000000000000e-01 -1.500000000000000e+00
|