-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_matrix.mojo
37 lines (37 loc) · 2.13 KB
/
test_matrix.mojo
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
29
30
31
32
33
34
35
36
37
from .matrix import Matrix
'''
fn test_matrix() -> None:
var test_matrix: Matrix = Matrix(Float64(3.14), 2, 2)
test_matrix.print_all()
let second_test_matrix: Matrix = Matrix(Float64(3.14), 2, 2)
debug_assert(not test_matrix < second_test_matrix, "Should not be less")
debug_assert(not test_matrix > second_test_matrix, "Should not be more")
debug_assert(test_matrix == second_test_matrix, "Should be equal")
debug_assert(not test_matrix != second_test_matrix, "Should not be not equal")
debug_assert(test_matrix >= second_test_matrix, "Should be greater than or equal")
debug_assert(test_matrix <= second_test_matrix, "Should be less than or equal")
test_matrix[0, 0] = Float64(1.5)
test_matrix[0, 1] = Float64(.33)
test_matrix[1, 0] = Float64(6.5)
test_matrix[1, 1] = Float64(2.5)
debug_assert(test_matrix < second_test_matrix, "Should be less")
debug_assert(not test_matrix > second_test_matrix, "Should not be more")
debug_assert(not test_matrix == second_test_matrix, "Should not be equal")
debug_assert(test_matrix != second_test_matrix, "Should be not equal")
debug_assert(not test_matrix >= second_test_matrix, "Should not be greater than or equal")
debug_assert(test_matrix <= second_test_matrix, "Should be less than or equal")
# No more debug_asserts because its been pretty well tested
let third_test_matrix: Matrix = test_matrix + second_test_matrix
let fourth_test_matrix: Matrix = test_matrix - second_test_matrix
let fifth_test_matrix: Matrix = test_matrix * second_test_matrix
let sixth_test_matrix: Matrix = test_matrix / second_test_matrix
let seventh_test_matrix: Matrix = test_matrix + Float64(1.0)
let eighth_test_matrix: Matrix = test_matrix - Float64(1.0)
let ninth_test_matrix: Matrix = test_matrix * Float64(1.0)
let tenth_test_matrix: Matrix = test_matrix / Float64(1.0)
@noncapturing
fn test_func(x: Float64) -> Float64:
return x * Float64(2.0)
# let eleventh_test_matrix: Matrix = test_matrix.apply_function[test_func]()
# let second_test: Matrix[] = [[Float32(1.5), Float32(.33)], [Float32(6.5), Float32(2.5)]]
'''