// 3rd_party_lib:matrix4cj/target/matrix4cj
// 3rd_party_lib_ohos:matrix4cj/target/aarch64-linux-ohos/matrix4cj
package matrix4cj.tests.HLT.LEVEL1
import matrix4cj.*
import std.math.*
import std.unittest.*
import std.unittest.testmacro.*
@Test
public class TestMatrix8 {
@TestCase
func L0_Test_Matrix_random_01(): Unit {
var rows = 4
var cols = 3
var matrix01 = Matrix.Random(rows, cols)
@Assert(matrix01.rowNum,rows)
@Assert(matrix01.colNum,cols)
}
@TestCase
func L0_Test_Matrix_random_02(): Unit {
var rows = 0
var cols = 0
try {
var matrix01 = Matrix.Random(rows, cols)
@Assert(false)
} catch (e: IllegalArgumentException) {
if (e.toString().contains("Matrix dimensions must be greater than zero.")) {
@Assert(true)
} else {
@Assert(false)
}
}
}
@TestCase
func L0_Test_Matrix_cond_01(): Unit {
var matrix01 = Matrix(
[
[1.80, 2.88, 2.05, -0.89],
[5.25, -2.95, -0.95, -3.80],
[1.58, -2.69, -2.90, -1.04],
[-1.11, -0.66, -0.59, 0.80]
]
)
var re = matrix01.cond()
@Assert(re,78.62108037257546)
}
@TestCase
func L0_Test_Matrix_cond_02(): Unit {
var matrix01 = Matrix(
[
[0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0]
]
)
var re = matrix01.cond()
@Assert(re.isNaN(),true)
}
@TestCase
func L0_Test_Matrix_cond_03(): Unit {
var matrix01 = Matrix([[1.80, 2.88, 2.80, 2.88], [-1.11, -0.66, -2.11, -1.66]])
var re = matrix01.cond()
@Assert(re,6.222763887122782)
}
@TestCase
func L0_Test_Matrix_cond_04(): Unit {
var matrix01 = Matrix(
[
[1.80, 2.88],
[2.80, 2.88],
[-1.11, -0.66],
[-2.11, -1.66]
]
)
var re = matrix01.cond()
@Assert(re,7.033908822406796)
}
@TestCase
func L0_Test_Matrix_cond_05(): Unit {
var matrix01 = Matrix(
[
[1.0, 0.0, 0.0, 0.0],
[0.0, 1.0, 0.0, 0.0],
[0.0, 0.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 1.0]
]
)
var re = matrix01.cond()
@Assert(re,1.0)
}
@TestCase
func L0_Test_Matrix_rank_01(): Unit {
var matrix01 = Matrix(
[
[1.80, 2.88, 2.05, -0.89],
[5.25, -2.95, -0.95, -3.80],
[1.58, -2.69, -2.90, -1.04],
[-1.11, -0.66, -0.59, 0.80]
]
)
var re = matrix01.rank()
@Assert(re,4)
}
@TestCase
func L0_Test_Matrix_rank_02(): Unit {
var matrix01 = Matrix(
[
[0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0]
]
)
var re = matrix01.rank()
@Assert(re,0)
}
@TestCase
func L0_Test_Matrix_rank_03(): Unit {
var matrix01 = Matrix([[1.80, 2.88, 2.80, 2.88], [-1.11, -0.66, -2.11, -1.66]])
var re = matrix01.rank()
@Assert(re,2)
}
@TestCase
func L0_Test_Matrix_rank_04(): Unit {
var matrix01 = Matrix(
[
[1.80, 2.88],
[2.80, 2.88],
[-1.11, -0.66],
[-2.11, -1.66]
]
)
var re = matrix01.rank()
@Assert(re,2)
}
}