@@ -19,3 +19,26 @@ def test01_tensor3d():
1919 a_colmaj = np .asfortranarray (a )
2020 with pytest .raises (TypeError , match = 'incompatible function arguments' ):
2121 t .square3dTensorR (a_colmaj )
22+
23+ # add3dTensor: col-major inputs (with implicit conversion from row-major)
24+ b = np .arange (12 , 24 , dtype = float ).reshape (2 , 3 , 2 )
25+ assert_array_equal (t .add3dTensor (a , b ), a + b )
26+ # row-major numpy arrays are implicitly converted
27+ assert_array_equal (t .add3dTensor (a , a ), a + a )
28+
29+ # add3dTensor_nc: noconvert — rejects row-major (C-order) arrays
30+ with pytest .raises (TypeError , match = 'incompatible function arguments' ):
31+ t .add3dTensor_nc (a , b )
32+ # Fortran-order (col-major) arrays are accepted without conversion
33+ assert_array_equal (t .add3dTensor_nc (a_colmaj , np .asfortranarray (b )), a + b )
34+
35+ # mul3dTensor: scalar * col-major tensor
36+ assert_array_equal (t .mul3dTensor (2.0 , a ), 2.0 * a )
37+
38+ # mul3dTensorMap: read-only TensorMap, returns a new tensor
39+ assert_array_equal (t .mul3dTensorMap (3.0 , a_colmaj ), 3.0 * a )
40+
41+ # mul3dTensorMapInPlace: mutates the array in place via TensorMap
42+ arr = np .asfortranarray (a .copy ())
43+ t .mul3dTensorMapInPlace (2.0 , arr )
44+ assert_array_equal (arr , 2.0 * a )
0 commit comments