Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[32-bit Linux] Investigate Linear Algebra failure #511

Open
mratsim opened this issue Jul 3, 2021 · 0 comments
Open

[32-bit Linux] Investigate Linear Algebra failure #511

mratsim opened this issue Jul 3, 2021 · 0 comments

Comments

@mratsim
Copy link
Owner

mratsim commented Jul 3, 2021

https://github.com/mratsim/Arraymancer/pull/510/checks?check_run_id=2980291716#step:21:823

image

The first failure may be due to rounding issue with float32 and switching to float64 will solve the issue.
1e-11 is way over float32 precision.

block: # p15 of http://www.cs.otago.ac.nz/cosc453/student_tutorials/principal_components.pdf
let a = [[0.616555556'f32, 0.615444444],
[0.615444444'f32, 0.716555556]].toTensor
let expected_val = [0.0490833989'f32, 1.28402771].toTensor
# Note: here the 1st vec is returned positive by Fortran (both are correct eigenvec)
let expected_vec = [[-0.735178656'f32, -0.677873399],
[ 0.677873399'f32, -0.735178656]].toTensor
let (val, vec) = symeig(a, true, 'U')
check: val.mean_absolute_error(expected_val) < 1e-7
for col in 0..<2:
check: mean_absolute_error( vec[_, col], expected_vec[_, col]) < 1e-11 or
mean_absolute_error(-vec[_, col], expected_vec[_, col]) < 1e-11

The second issue is very strange though

test "LU Factorization":
block: # M > N
# import numpy as np
# from scipy.linalg import lu
# np.set_printoptions(suppress=True) # Don't use scientific notation
# a = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]])
# pl, u = lu(a, permute_l = True)
# print(pl)
# print(u)
let a = [[ 1.0, 2, 3],
[ 4.0, 5, 6],
[ 7.0, 8, 9],
[10.0,11,12]].toTensor()
let expected_pl = [[0.1, 1 , 0],
[0.4, 0.66666667, 0],
[0.7, 0.33333333, 1],
[1.0, 0 , 0]].toTensor()
let expected_u = [[10.0, 11.0, 12.0],
[ 0.0, 0.9, 1.8],
[ 0.0, 0.0, 0.0]].toTensor()
let (PL, U) = lu_permuted(a)
check:
PL.mean_absolute_error(expected_pl) < 1e-8
U.mean_absolute_error(expected_u) < 1e-8

@mratsim mratsim changed the title [-bit Linux] Investigate Linear Algebra failure [32-bit Linux] Investigate Linear Algebra failure Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant