// 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 TestMatrix7 {
    @TestCase
    func L0_Test_Matrix_times01_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 result = matrix01*(10.33)
        var expected_matrix = Matrix(
            [
                [18.594, 29.7504, 21.176499999999997, -9.1937],
                [54.2325, -30.4735, -9.8135, -39.254],
                [16.3214, -27.7877, -29.957, -10.7432],
                [-11.4663, -6.8178, -6.0947, 8.264000000000001]
            ]
        )
        @Assert(result.rowNum,expected_matrix.rowNum)
        @Assert(result.colNum,expected_matrix.colNum)
        var rows = result.rowNum
        var cols = result.colNum
        for (i in 0..rows) {
            for (j in 0..cols) {
                @Assert(abs(expected_matrix.get(i,j)-result.get(i,j))<1e-6,true)
                @Assert(abs(expected_matrix.get(i,j)-matrix01.get(i,j))<1e-6,false)
            }
        }
    }
    @TestCase
    func L0_Test_Matrix_times01_02(): 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 result = matrix01 * (0.0)
        var expected_matrix = 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]
            ]
        )
        @Assert(result.rowNum,expected_matrix.rowNum)
        @Assert(result.colNum,expected_matrix.colNum)
        var rows = result.rowNum
        var cols = result.colNum
        for (i in 0..rows) {
            for (j in 0..cols) {
                @Assert(abs(expected_matrix.get(i,j)-result.get(i,j))<1e-6,true)
                @Assert(abs(expected_matrix.get(i,j)-matrix01.get(i,j))<1e-6,false)
            }
        }
    }
    @TestCase
    func L0_Test_Matrix_times01_03(): 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 result = matrix01 * (-10.33)
        var expected_matrix = Matrix(
            [
                [-18.594, -29.7504, -21.176499999999997, 9.1937],
                [-54.2325, 30.4735, 9.8135, 39.254],
                [-16.3214, 27.7877, 29.957, 10.7432],
                [11.4663, 6.8178, 6.0947, -8.264000000000001]
            ]
        )
        @Assert(result.rowNum,expected_matrix.rowNum)
        @Assert(result.colNum,expected_matrix.colNum)
        var rows = result.rowNum
        var cols = result.colNum
        for (i in 0..rows) {
            for (j in 0..cols) {
                @Assert(abs(expected_matrix.get(i,j)-result.get(i,j))<1e-6,true)
                @Assert(abs(expected_matrix.get(i,j)-matrix01.get(i,j))<1e-6,false)
            }
        }
    }
    @TestCase
    func L0_Test_Matrix_times02_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 result = matrix01 * (matrix01)
        var expected_matrix = Matrix(
            [
                [22.5869, -8.239099999999999, -4.4658999999999995, -15.389999999999999],
                [-3.320499999999999, 28.885999999999996, 18.562, 4.485500000000001],
                [-14.706100000000001, 20.9733, 14.8181, 10.999799999999999],
                [-7.283200000000001, -0.19069999999999987, -0.4095000000000002, 4.749500000000001]
            ]
        )
        @Assert(result.rowNum,expected_matrix.rowNum)
        @Assert(result.colNum,expected_matrix.colNum)
        var rows = result.rowNum
        var cols = result.colNum
        for (i in 0..rows) {
            for (j in 0..cols) {
                @Assert(abs(expected_matrix.get(i,j)-result.get(i,j))<1e-6,true)
                @Assert(abs(expected_matrix.get(i,j)-matrix01.get(i,j))<1e-6,false)
            }
        }
    }
    @TestCase
    func L0_Test_Matrix_times02_03(): 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 matrix02 = Matrix(
            [
                [1.80, 2.88],
                [-1.11, -0.66],
                [2.80, 2.88],
                [-2.11, -1.66]
            ]
        )
        var result = matrix01 * (matrix02)
        var expected_matrix = Matrix(
            [
                [7.661099999999999, 10.664599999999998],
                [18.082500000000003, 20.639],
                [-0.09569999999999901, -0.2998000000000003],
                [-4.6053999999999995, -5.7884]
            ]
        )
        @Assert(result.rowNum,expected_matrix.rowNum)
        @Assert(result.colNum,expected_matrix.colNum)
        var rows = result.rowNum
        var cols = result.colNum
        for (i in 0..rows) {
            for (j in 0..cols) {
                @Assert(abs(expected_matrix.get(i,j)-result.get(i,j))<1e-6,true)
                @Assert(abs(expected_matrix.get(i,j)-matrix01.get(i,j))<1e-6,false)
            }
        }
    }
    @TestCase
    func L0_Test_Matrix_timesEquals_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]
            ]
        )
        matrix01 *= (10.33)
        var result = matrix01
        var expected_matrix = Matrix(
            [
                [18.594, 29.7504, 21.176499999999997, -9.1937],
                [54.2325, -30.4735, -9.8135, -39.254],
                [16.3214, -27.7877, -29.957, -10.7432],
                [-11.4663, -6.8178, -6.0947, 8.264000000000001]
            ]
        )
        @Assert(result.rowNum,expected_matrix.rowNum)
        @Assert(result.colNum,expected_matrix.colNum)
        var rows = result.rowNum
        var cols = result.colNum
        for (i in 0..rows) {
            for (j in 0..cols) {
                @Assert(abs(expected_matrix.get(i,j)-result.get(i,j))<1e-6,true)
                @Assert(abs(expected_matrix.get(i,j)-matrix01.get(i,j))<1e-6,true)
            }
        }
    }
    @TestCase
    func L0_Test_Matrix_timesEquals_02(): 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]
            ]
        )
        matrix01 *= (0.0)
        var result = matrix01
        var expected_matrix = 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]
            ]
        )
        @Assert(result.rowNum,expected_matrix.rowNum)
        @Assert(result.colNum,expected_matrix.colNum)
        var rows = result.rowNum
        var cols = result.colNum
        for (i in 0..rows) {
            for (j in 0..cols) {
                @Assert(abs(expected_matrix.get(i,j)-result.get(i,j))<1e-6,true)
                @Assert(abs(expected_matrix.get(i,j)-matrix01.get(i,j))<1e-6,true)
            }
        }
    }
    @TestCase
    func L0_Test_Matrix_timesEquals_03(): 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]
            ]
        )
        matrix01 *= (-10.33)
        var result = matrix01
        var expected_matrix = Matrix(
            [
                [-18.594, -29.7504, -21.176499999999997, 9.1937],
                [-54.2325, 30.4735, 9.8135, 39.254],
                [-16.3214, 27.7877, 29.957, 10.7432],
                [11.4663, 6.8178, 6.0947, -8.264000000000001]
            ]
        )
        @Assert(result.rowNum,expected_matrix.rowNum)
        @Assert(result.colNum,expected_matrix.colNum)
        var rows = result.rowNum
        var cols = result.colNum
        for (i in 0..rows) {
            for (j in 0..cols) {
                @Assert(abs(expected_matrix.get(i,j)-result.get(i,j))<1e-6,true)
                @Assert(abs(expected_matrix.get(i,j)-matrix01.get(i,j))<1e-6,true)
            }
        }
    }
}