Package com.polytechnik.utils
Class Linsystems
java.lang.Object
com.polytechnik.utils.Linsystems
Linear system solver.
copied from http://netlib.org/benchmark/linpackjava/Linpack.java
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
checkInverted
(int n_tests, Random r, double eps) private static void
checkMatrs
(int n, int nlda, int info, int info1d, double[][] a, double[] a1d, int[] ipvt, int[] ipvt1d) private static void
checkMatrs2
(int n, double[] r, double[] r1d) private static void
checkSystem
(double[][] matr, double[] rightpart, boolean diag) private static void
daxpy
(int n, double da, double[] dx, int dx_off, int incx, double[] dy, int dy_off, int incy) constant times a vector plus a vector.private static double
ddot
(int n, double[] dx, int dx_off, int incx, double[] dy, int dy_off, int incy) forms the dot product of two vectors.static int
dgefa
(double[][] a, int n, int[] ipvt) static int
dgefa_m1
(double[] a, int n, int nlda, int[] ipvt) The same as dgefa, but store matrix in 1D array.static void
dgesl
(double[][] a, int n, int[] ipvt, double[] b, int job) dgesl solves the double precision system a * x = b or trans(a) * x = b using the factors computed by dgeco or dgefa.static void
dgesl_m1
(double[] a, int n, int nlda, int[] ipvt, double[] b, int job) private static void
dscal
(int n, double da, double[] dx, int dx_off, int incx) scales a vector by a constant.static double[][]
getInvertedMatrix
(double[][] matr) A crude way to invert a matrix.static double[][]
getInvertedMatrix
(int n, double[][] matr) A crude way to invert a matrix.static double[]
getInvertedMatrix
(int n, int nlda, double[] matr) A crude way to invert a matrix.private static int
idamax
(int n, double[] dx, int dx_off, int incx) finds the index of element having max.static void
Simple test.(package private) static void
test_linsys
(String txt, int n, int ntests, Random r)
-
Constructor Details
-
Linsystems
public Linsystems()
-
-
Method Details
-
main
Simple test. -
checkSystem
private static void checkSystem(double[][] matr, double[] rightpart, boolean diag) -
dgefa
public static int dgefa(double[][] a, int n, int[] ipvt) -
dgesl
public static void dgesl(double[][] a, int n, int[] ipvt, double[] b, int job) dgesl solves the double precision system a * x = b or trans(a) * x = b using the factors computed by dgeco or dgefa. on entry a double precision[n][n] the output from dgeco or dgefa. n integer the order of the matrix a . ipvt integer[n] the pivot vector from dgeco or dgefa. b double precision[n] the right hand side vector. job integer = 0 to solve a*x = b , = nonzero to solve trans(a)*x = b where trans(a) is the transpose. on return b the solution vector x . error condition a division by zero will occur if the input factor contains a zero on the diagonal. technically this indicates singularity but it is often caused by improper arguments or improper setting of lda . it will not occur if the subroutines are called correctly and if dgeco has set rcond .gt. 0.0 or dgefa has set info .eq. 0 . to compute inverse(a) * c where c is a matrix with p columns dgeco(a,lda,n,ipvt,rcond,z) if (!rcond is too small){ for (j=0,j<p,j++) dgesl(a,lda,n,ipvt,c[j][0],0); } linpack. this version dated 08/14/78 . cleve moler, university of new mexico, argonne national lab. functions blas daxpy,ddot here job=0 a[j][i]*r[j]=b[i] here job=1 a[i][j]*r[j]=b[i] -
daxpy
private static void daxpy(int n, double da, double[] dx, int dx_off, int incx, double[] dy, int dy_off, int incy) constant times a vector plus a vector. jack dongarra, linpack, 3/11/78. -
ddot
private static double ddot(int n, double[] dx, int dx_off, int incx, double[] dy, int dy_off, int incy) forms the dot product of two vectors. jack dongarra, linpack, 3/11/78. -
dscal
private static void dscal(int n, double da, double[] dx, int dx_off, int incx) scales a vector by a constant. jack dongarra, linpack, 3/11/78. -
idamax
private static int idamax(int n, double[] dx, int dx_off, int incx) finds the index of element having max. absolute value. jack dongarra, linpack, 3/11/78. -
getInvertedMatrix
public static double[][] getInvertedMatrix(double[][] matr) A crude way to invert a matrix. -
getInvertedMatrix
public static double[][] getInvertedMatrix(int n, double[][] matr) A crude way to invert a matrix. -
getInvertedMatrix
public static double[] getInvertedMatrix(int n, int nlda, double[] matr) A crude way to invert a matrix. Returned matrix has a leading dimension n. -
dgesl_m1
public static void dgesl_m1(double[] a, int n, int nlda, int[] ipvt, double[] b, int job) -
dgefa_m1
public static int dgefa_m1(double[] a, int n, int nlda, int[] ipvt) The same as dgefa, but store matrix in 1D array. -
checkMatrs2
private static void checkMatrs2(int n, double[] r, double[] r1d) -
checkMatrs
private static void checkMatrs(int n, int nlda, int info, int info1d, double[][] a, double[] a1d, int[] ipvt, int[] ipvt1d) -
checkInverted
-
test_linsys
-