BLAS Library Functions
According to the writing style of the Java language, matrices are in row-major order by default.
Enumeration Type
Table 1 describes the BLAS enumeration types in KML_JAVA.
Enumeration Type |
Description |
Syntax |
|---|---|---|
Transpose |
Defines whether to transpose the original or conjugated matrix. |
public enum Transpose { NO_TRANS(111), TRANS(112), CONJ_TRANS(113), CONJ_NO_TRANS(114); } |
Uplo |
Defines whether to use the upper triangular part or lower triangular part of the matrix. |
public enum Uplo { UPPER=121, LOWER=122; } |
Diag |
Defines whether the used matrix is a unit matrix. |
public enum Diag { NON_UNIT=131, UNIT=132; } |
Side |
Defines whether the matrix appears on the left or right in the operation. |
public enum Side { LEFT=141, RIGHT=142; } |
Dependencies
import com.huawei.kml.BLAS;
If enumeration is required, explicitly declare as follows:
import com.huawei.kml.BLAS.Diag;
import com.huawei.kml.BLAS.Side;
import com.huawei.kml.BLAS.Transpose;
import com.huawei.kml.BLAS.Uplo;
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | public class DMMTest { void testGemm() { int sizeM = 4; int sizeN = 4; int sizeK = 3; double[] matrixA = new double[]{ 0.340188, 0.411647, -0.222225, -0.105617, -0.302449, 0.053970, 0.283099, -0.164777, -0.022603, 0.298440, 0.268230, 0.128871}; double[] matrixB = new double[]{ -0.135216, 0.416195, -0.358397, -0.257113, 0.013401, 0.135712, 0.106969, -0.362768, 0.452230, 0.217297, -0.483699, 0.304177}; double[] matrixC = new double[]{ -0.343321, 0.498924, 0.112640, -0.006417, -0.099056, -0.281743, -0.203968, 0.472775, -0.370210, 0.012932, 0.137552, -0.207483, -0.391191, 0.339112, 0.024287, 0.271358}; double alpha = 1.0; double beta = 2.0; BLAS.dgemm( Transpose.NO_TRANS, Transpose.NO_TRANS, sizeM, sizeN, sizeK, alpha, matrixA, sizeK, matrixB, sizeN, beta, matrixC, sizeN); } } /* * matrixC: * -0.827621 1.147010 0.254881 -0.317229 * -0.163476 -0.636762 -0.428542 1.098841 * -0.791128 0.116416 0.166949 -0.434854 * -0.760862 0.866839 -0.092028 0.407877 * */ |