Class Blas
This class contains Java versions of a number of the LINPACK basic linear algebra subroutines (blas):
- isamax_j
- daxpy_j
- ddot_j
- dscal_j
- dswap_j
- dnrm2_j
- dcopy_j
- drotg_j
- colisamax_j
- colaxpy_j
- colvaxpy_j
- colvraxpy_j
- coldot_j
- colvdot_j
- colscal_j
- dscalp_j
- colswap_j
- colnrm2_j
- dnrm2p_j
- dcopyp_j
- colrot_j
- sign_j
IMPORTANT: The "_j" suffixes indicate that these routines use Java style indexing. For example, you will see for (i = 0; i invalid input: '<' n; i++) rather than (FORTRAN style) for (i = 1; i invalid input: '<'= n; i++) To use the "_j" routines you will have to fill elements 0 through n - 1 of vectors rather than elements 1 through n. [Also, before using the isamax and colisamax methods make sure that they are doing what you expect them to do.] Versions of these programs that use FORTRAN style indexing are also available. They end with the suffix "_f77".
This class was translated by a statistician from FORTRAN versions of the LINPACK blas. It is NOT an official translation. When public domain Java numerical analysis routines become available from the people who produce LAPACK, then THE CODE PRODUCED BY THE NUMERICAL ANALYSTS SHOULD BE USED.
Meanwhile, if you have suggestions for improving this code, please contact Steve Verrill at sverrill@fs.fed.us.
- Version:
- .5 --- June 3, 1997
- Author:
- Steve Verrill
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
colaxpy_j
(int nrow, double a, double[][] x, int begin, int j1, int j2) This method multiplies a constant times a portion of a column of a matrix and adds the product to the corresponding portion of another column of the matrix --- a portion of col2 is replaced by the corresponding portion of a*col1 + col2.static double
coldot_j
(int nrow, double[][] x, int begin, int j1, int j2) This method calculates the dot product of portions of two columns of a matrix.static int
colisamax_j
(int n, double[][] x, int incx, int begin, int j) This method finds the index of the element of a portion of a column of a matrix that has the maximum absolute value.static double
colnrm2_j
(int nrow, double[][] x, int begin, int j) This method calculates the Euclidean norm of a portion of a column of a matrix.static void
colrot_j
(int n, double[][] x, int j1, int j2, double c, double s) This method "applies a plane rotation."static void
colscal_j
(int nrow, double a, double[][] x, int begin, int j) This method scales a portion of a column of a matrix by a constant.static void
colswap_j
(int n, double[][] x, int j1, int j2) This method interchanges two columns of a matrix.static void
colvaxpy_j
(int nrow, double a, double[][] x, double[] y, int begin, int j) This method multiplies a constant times a portion of a column of a matrix x[invalid input: ' '][invalid input: ' '] and adds the product to the corresponding portion of a vector y[invalid input: ' '] --- a portion of y[invalid input: ' '] is replaced by the corresponding portion of ax[invalid input: ' '][j] + y[invalid input: ' '].static double
colvdot_j
(int nrow, double[][] x, double[] y, int begin, int j) This method calculates the dot product of a portion of a column of a matrix and the corresponding portion of a vector.static void
colvraxpy_j
(int nrow, double a, double[] y, double[][] x, int begin, int j) This method multiplies a constant times a portion of a vector y[invalid input: ' '] and adds the product to the corresponding portion of a column of a matrix x[invalid input: ' '][invalid input: ' '] --- a portion of column j of x[invalid input: ' '][invalid input: ' '] is replaced by the corresponding portion of ay[invalid input: ' '] + x[invalid input: ' '][j].static void
daxpy_j
(int n, double da, double[] dx, int incx, double[] dy, int incy) This method multiplies a constant times a vector and adds the product to another vector --- dy[invalid input: ' '] = da*dx[invalid input: ' '] + dy[invalid input: ' '].static void
dcopy_j
(int n, double[] dx, int incx, double[] dy, int incy) This method copies the vector dx[invalid input: ' '] to the vector dy[invalid input: ' '].static void
dcopyp_j
(int nrow, double[] x, double[] y, int begin) This method copies a portion of vector x[invalid input: ' '] to the corresponding portion of vector y[invalid input: ' '].static double
ddot_j
(int n, double[] dx, int incx, double[] dy, int incy) This method calculates the dot product of two vectors.static double
dnrm2_j
(int n, double[] x, int incx) This method calculates the Euclidean norm of the vector stored in dx[invalid input: ' '] with storage increment incx.static double
dnrm2p_j
(int nrow, double[] x, int begin) This method calculates the Euclidean norm of a portion of a vector x[invalid input: ' '].static void
drotg_j
(double[] rotvec) This method constructs a Givens plane rotation.static void
dscal_j
(int n, double da, double[] dx, int incx) This method scales a vector by a constant.static void
dscalp_j
(int nrow, double a, double[] x, int begin) This method scales a portion of a vector by a constant.static void
dswap_j
(int n, double[] dx, int incx, double[] dy, int incy) This method interchanges two vectors.static int
isamax_j
(int n, double[] x, int incx) This method finds the index of the element of a vector that has the maximum absolute value.static void
matmat_j
(double[][] a, double[][] b, double[][] c, int n, int p, int r) This method multiplies an n x p matrix by a p x r matrix.static void
mattran_j
(double[][] a, double[][] at, int n, int p) This method obtains the transpose of an n x p matrix.static void
matvec_j
(double[][] a, double[] b, double[] c, int n, int p) This method multiplies an n x p matrix by a p x 1 vector.static double
sign_j
(double a, double b) This method implements the FORTRAN sign (not sin) function.
-
Constructor Details
-
Blas
public Blas()
-
-
Method Details
-
colaxpy_j
public static void colaxpy_j(int nrow, double a, double[][] x, int begin, int j1, int j2) This method multiplies a constant times a portion of a column of a matrix and adds the product to the corresponding portion of another column of the matrix --- a portion of col2 is replaced by the corresponding portion of a*col1 + col2. It uses unrolled loops. It is a modification of the LINPACK subroutine DAXPY. In the LINPACK listing DAXPY is attributed to Jack Dongarra with a date of 3/11/78. Translated and modified by Steve Verrill, February 26, 1997.
- Parameters:
nrow
- The number of rows involveda
- The constantx
- [invalid input: ' '][invalid input: ' '] The matrixbegin
- The starting rowj1
- The id of col1j2
- The id of col2
-
coldot_j
public static double coldot_j(int nrow, double[][] x, int begin, int j1, int j2) This method calculates the dot product of portions of two columns of a matrix. It uses unrolled loops. It is a modification of the LINPACK function DDOT. In the LINPACK listing DDOT is attributed to Jack Dongarra with a date of 3/11/78. Translated and modified by Steve Verrill, February 27, 1997.
- Parameters:
nrow
- The number of rows involvedx
- [invalid input: ' '][invalid input: ' '] The matrixbegin
- The starting rowj1
- The id of the first columnj2
- The id of the second column
-
colisamax_j
public static int colisamax_j(int n, double[][] x, int incx, int begin, int j) This method finds the index of the element of a portion of a column of a matrix that has the maximum absolute value. It is a modification of the LINPACK function ISAMAX. In the LINPACK listing ISAMAX is attributed to Jack Dongarra with a date of March 11, 1978. Translated by Steve Verrill, March 10, 1998.
- Parameters:
n
- The number of elements to be checkedx
- [invalid input: ' '][invalid input: ' '] The matrixincx
- The subscript increment for x[invalid input: ' '][invalid input: ' ']begin
- The starting rowj
- The id of the column
-
colnrm2_j
public static double colnrm2_j(int nrow, double[][] x, int begin, int j) This method calculates the Euclidean norm of a portion of a column of a matrix. It is a modification of the LINPACK function dnrm2. In the LINPACK listing dnrm2 is attributed to C.L. Lawson with a date of January 8, 1978. The routine below is based on a more recent dnrm2 version that is attributed in LAPACK documentation to Sven Hammarling. Translated and modified by Steve Verrill, February 26, 1997.
- Parameters:
nrow
- The number of rows involvedx
- [invalid input: ' '][invalid input: ' '] The matrixbegin
- The starting rowj
- The id of the column
-
colrot_j
public static void colrot_j(int n, double[][] x, int j1, int j2, double c, double s) This method "applies a plane rotation." It is a modification of the LINPACK function DROT. In the LINPACK listing DROT is attributed to Jack Dongarra with a date of 3/11/78. Translated and modified by Steve Verrill, March 4, 1997.
- Parameters:
n
- The order of x[invalid input: ' '][invalid input: ' ']x
- [invalid input: ' '][invalid input: ' '] The matrixj1
- The id of the first columnj2
- The id of the second columnc
- "cos"s
- "sin"
-
colscal_j
public static void colscal_j(int nrow, double a, double[][] x, int begin, int j) This method scales a portion of a column of a matrix by a constant. It uses unrolled loops. It is a modification of the LINPACK subroutine DSCAL. In the LINPACK listing DSCAL is attributed to Jack Dongarra with a date of 3/11/78. Translated and modified by Steve Verrill, February 27, 1997.
- Parameters:
nrow
- The number of rows involveda
- The constantx
- [invalid input: ' '][invalid input: ' '] The matrixbegin
- The starting rowj
- The id of the column
-
colswap_j
public static void colswap_j(int n, double[][] x, int j1, int j2) This method interchanges two columns of a matrix. It uses unrolled loops. It is a modification of the LINPACK function DSWAP. In the LINPACK listing DSWAP is attributed to Jack Dongarra with a date of 3/11/78. Translated and modified by Steve Verrill, February 26, 1997.
- Parameters:
n
- The number of rows of the matrixx
- [invalid input: ' '][invalid input: ' '] The matrixj1
- The id of the first columnj2
- The id of the second column
-
colvaxpy_j
public static void colvaxpy_j(int nrow, double a, double[][] x, double[] y, int begin, int j) This method multiplies a constant times a portion of a column of a matrix x[invalid input: ' '][invalid input: ' '] and adds the product to the corresponding portion of a vector y[invalid input: ' '] --- a portion of y[invalid input: ' '] is replaced by the corresponding portion of ax[invalid input: ' '][j] + y[invalid input: ' ']. It uses unrolled loops. It is a modification of the LINPACK subroutine DAXPY. In the LINPACK listing DAXPY is attributed to Jack Dongarra with a date of 3/11/78. Translated and modified by Steve Verrill, March 1, 1997.
- Parameters:
nrow
- The number of rows involveda
- The constantx
- [invalid input: ' '][invalid input: ' '] The matrixy
- [invalid input: ' '] The vectorbegin
- The starting rowj
- The id of the column of the x matrix
-
colvdot_j
public static double colvdot_j(int nrow, double[][] x, double[] y, int begin, int j) This method calculates the dot product of a portion of a column of a matrix and the corresponding portion of a vector. It uses unrolled loops. It is a modification of the LINPACK function DDOT. In the LINPACK listing DDOT is attributed to Jack Dongarra with a date of 3/11/78. Translated and modified by Steve Verrill, March 1, 1997.
- Parameters:
nrow
- The number of rows involvedx
- [invalid input: ' '][invalid input: ' '] The matrixy
- [invalid input: ' '] The vectorbegin
- The starting rowj
- The id of the column of the matrix
-
colvraxpy_j
public static void colvraxpy_j(int nrow, double a, double[] y, double[][] x, int begin, int j) This method multiplies a constant times a portion of a vector y[invalid input: ' '] and adds the product to the corresponding portion of a column of a matrix x[invalid input: ' '][invalid input: ' '] --- a portion of column j of x[invalid input: ' '][invalid input: ' '] is replaced by the corresponding portion of ay[invalid input: ' '] + x[invalid input: ' '][j]. It uses unrolled loops. It is a modification of the LINPACK subroutine DAXPY. In the LINPACK listing DAXPY is attributed to Jack Dongarra with a date of 3/11/78. Translated and modified by Steve Verrill, March 3, 1997.
- Parameters:
nrow
- The number of rows involveda
- The constanty
- [invalid input: ' '] The vectorx
- [invalid input: ' '][invalid input: ' '] The matrixbegin
- The starting rowj
- The id of the column of the x matrix
-
daxpy_j
public static void daxpy_j(int n, double da, double[] dx, int incx, double[] dy, int incy) This method multiplies a constant times a vector and adds the product to another vector --- dy[invalid input: ' '] = da*dx[invalid input: ' '] + dy[invalid input: ' ']. It uses unrolled loops for increments equal to one. It is a translation from FORTRAN to Java of the LINPACK subroutine DAXPY. In the LINPACK listing DAXPY is attributed to Jack Dongarra with a date of 3/11/78. Translated by Steve Verrill, June 3, 1997.
- Parameters:
n
- The order of the vectors dy[invalid input: ' '] and dx[invalid input: ' ']da
- The constantdx
- [invalid input: ' '] This vector will be multiplied by the constant daincx
- The subscript increment for dx[invalid input: ' ']dy
- [invalid input: ' '] This vector will be added to da*dx[invalid input: ' ']incy
- The subscript increment for dy[invalid input: ' ']
-
dcopy_j
public static void dcopy_j(int n, double[] dx, int incx, double[] dy, int incy) This method copies the vector dx[invalid input: ' '] to the vector dy[invalid input: ' ']. It uses unrolled loops for increments equal to one. It is a translation from FORTRAN to Java of the LINPACK subroutine DCOPY. In the LINPACK listing DCOPY is attributed to Jack Dongarra with a date of 3/11/78. Translated by Steve Verrill, March 1, 1997.
- Parameters:
n
- The order of dx[invalid input: ' '] and dy[invalid input: ' ']dx
- [invalid input: ' '] vectorincx
- The subscript increment for dx[invalid input: ' ']dy
- [invalid input: ' '] vectorincy
- The subscript increment for dy[invalid input: ' ']
-
dcopyp_j
public static void dcopyp_j(int nrow, double[] x, double[] y, int begin) This method copies a portion of vector x[invalid input: ' '] to the corresponding portion of vector y[invalid input: ' ']. It uses unrolled loops. It is a modification of the LINPACK subroutine dcopy. In the LINPACK listing dcopy is attributed to Jack Dongarra with a date of 3/11/78. Translated by Steve Verrill, March 1, 1997.
- Parameters:
nrow
- The number of rows involvedx
- [invalid input: ' '] vectory
- [invalid input: ' '] vectorbegin
- The starting row
-
ddot_j
public static double ddot_j(int n, double[] dx, int incx, double[] dy, int incy) This method calculates the dot product of two vectors. It uses unrolled loops for increments equal to one. It is a translation from FORTRAN to Java of the LINPACK function DDOT. In the LINPACK listing DDOT is attributed to Jack Dongarra with a date of 3/11/78. Translated by Steve Verrill, June 3, 1997.
- Parameters:
n
- The order of the vectors dx[invalid input: ' '] and dy[invalid input: ' ']dx
- [invalid input: ' '] vectorincx
- The subscript increment for dx[invalid input: ' ']dy
- [invalid input: ' '] vectorincy
- The subscript increment for dy[invalid input: ' ']
-
dnrm2_j
public static double dnrm2_j(int n, double[] x, int incx) This method calculates the Euclidean norm of the vector stored in dx[invalid input: ' '] with storage increment incx. It is a translation from FORTRAN to Java of the LINPACK function DNRM2. In the LINPACK listing DNRM2 is attributed to C.L. Lawson with a date of January 8, 1978. The routine below is based on a more recent DNRM2 version that is attributed in LAPACK documentation to Sven Hammarling. Translated by Steve Verrill, June 3, 1997.
- Parameters:
n
- The order of the vector x[invalid input: ' ']x
- [invalid input: ' '] vectorincx
- The subscript increment for x[invalid input: ' ']
-
dnrm2p_j
public static double dnrm2p_j(int nrow, double[] x, int begin) This method calculates the Euclidean norm of a portion of a vector x[invalid input: ' ']. It is a modification of the LINPACK function dnrm2. In the LINPACK listing dnrm2 is attributed to C.L. Lawson with a date of January 8, 1978. The routine below is based on a more recent dnrm2 version that is attributed in LAPACK documentation to Sven Hammarling. Translated by Steve Verrill, March 3, 1997.
- Parameters:
nrow
- The number of rows involvedx
- [invalid input: ' '] vectorbegin
- The starting row
-
drotg_j
public static void drotg_j(double[] rotvec) This method constructs a Givens plane rotation. It is a translation from FORTRAN to Java of the LINPACK subroutine DROTG. In the LINPACK listing DROTG is attributed to Jack Dongarra with a date of 3/11/78. Translated by Steve Verrill, March 3, 1997.
- Parameters:
rotvec
- [] Contains the a,b,c,s values. In Java they cannot be passed as primitive types (e.g., double or int or ...) if we want their return values to be altered.
-
dscal_j
public static void dscal_j(int n, double da, double[] dx, int incx) This method scales a vector by a constant. It uses unrolled loops for an increment equal to one. It is a translation from FORTRAN to Java of the LINPACK subroutine DSCAL. In the LINPACK listing DSCAL is attributed to Jack Dongarra with a date of 3/11/78. Translated by Steve Verrill, June 3, 1997.
- Parameters:
n
- The order of the vector dx[invalid input: ' ']da
- The constantdx
- [invalid input: ' '] This vector will be multiplied by the constant daincx
- The subscript increment for dx[invalid input: ' ']
-
dscalp_j
public static void dscalp_j(int nrow, double a, double[] x, int begin) This method scales a portion of a vector by a constant. It uses unrolled loops. It is a modification of the LINPACK subroutine DSCAL. In the LINPACK listing DSCAL is attributed to Jack Dongarra with a date of 3/11/78. Translated and modified by Steve Verrill, March 3, 1997.
- Parameters:
nrow
- The number of rows involveda
- The constantx
- [invalid input: ' '] The vectorbegin
- The starting row
-
dswap_j
public static void dswap_j(int n, double[] dx, int incx, double[] dy, int incy) This method interchanges two vectors. It uses unrolled loops for increments equal to one. It is a translation from FORTRAN to Java of the LINPACK function DSWAP. In the LINPACK listing DSWAP is attributed to Jack Dongarra with a date of 3/11/78. Translated by Steve Verrill, June 3, 1997.
- Parameters:
n
- The order of the vectors dx[invalid input: ' '] and dy[invalid input: ' ']dx
- [invalid input: ' '] vectorincx
- The subscript increment for dx[invalid input: ' ']dy
- [invalid input: ' '] vectorincy
- The subscript increment for dy[invalid input: ' ']
-
isamax_j
public static int isamax_j(int n, double[] x, int incx) This method finds the index of the element of a vector that has the maximum absolute value. It is a translation from FORTRAN to Java of the LINPACK function ISAMAX. In the LINPACK listing ISAMAX is attributed to Jack Dongarra with a date of March 11, 1978. Before you use this version of isamax, make certain that it is doing what you expect it to do. Translated by Steve Verrill, March 10, 1998.
- Parameters:
n
- The number of elements to be checkedx
- [invalid input: ' '] vectorincx
- The subscript increment for x[invalid input: ' ']
-
matmat_j
public static void matmat_j(double[][] a, double[][] b, double[][] c, int n, int p, int r) This method multiplies an n x p matrix by a p x r matrix. Created by Steve Verrill, March 1997.
- Parameters:
a
- [invalid input: ' '][invalid input: ' '] The left matrixb
- [invalid input: ' '][invalid input: ' '] The right matrixc
- [invalid input: ' '][invalid input: ' '] The productn
- np
- pr
- r
-
mattran_j
public static void mattran_j(double[][] a, double[][] at, int n, int p) This method obtains the transpose of an n x p matrix. Created by Steve Verrill, March 1997.- Parameters:
a
- [invalid input: ' '][invalid input: ' '] matrixat
- [invalid input: ' '][invalid input: ' '] transpose of the matrixn
- np
- p
-
matvec_j
public static void matvec_j(double[][] a, double[] b, double[] c, int n, int p) This method multiplies an n x p matrix by a p x 1 vector. Created by Steve Verrill, March 1997.- Parameters:
a
- [invalid input: ' '][invalid input: ' '] The matrixb
- [invalid input: ' '] The vectorc
- [invalid input: ' '] The productn
- np
- p
-
sign_j
public static double sign_j(double a, double b) This method implements the FORTRAN sign (not sin) function. See the code for details. Created by Steve Verrill, March 1997.- Parameters:
a
- ab
- b
-