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

Compilation error when usinf least_squares_solver #496

Closed
lscrd opened this issue Feb 19, 2021 · 1 comment
Closed

Compilation error when usinf least_squares_solver #496

lscrd opened this issue Feb 19, 2021 · 1 comment

Comments

@lscrd
Copy link

lscrd commented Feb 19, 2021

Hi,

When using “least_squares_solver” I get a compilation error.

Here is an example:

import arraymancer

var a = [[1.0, 2.0], [1.0, 7.0]].toTensor
var b = [2.0, 4.0].toTensor

echo leastSquaresSolver(a, b)

And here is the error:

/...../.nimble/pkgs/arraymancer-0.6.2/arraymancer/linear_algebra/least_squares.nim(16, 8) template/generic instantiation of `gelsd` from here
/....../.nimble/pkgs/arraymancer-0.6.2/arraymancer/linear_algebra/helpers/least_squares_lapack.nim(75, 85) Error: type mismatch: got <int32, int literal(2)>
but expected one of: 
template `^`(x: int): BackwardsIndex
  first type mismatch at position: 2
  extra argument given

2 other mismatching symbols have been suppressed; compile with --showAllMismatches:on to see them

expression: 26'i32 ^ 2

Looking into “arraymancer/linear_algebra/helpers/least_squares_lapack.nim” it appears that the error occurs in this line:

lwork = max(1, 12 * m + 2 * m * smlsiz + 8 * m * nlvl + m * nrhs + (smlsiz + 1) ^ 2)

and especially with (smlsiz + 1) ^ 2.

It looks like the operator ^ for integers is not available at this point.

I have been able to solve the issue either by replacing (smlsiz + 1) ^ 2 with (smlsiz + 1) * (smlsiz + 1) or by adding somewhere from math import `^` .

Of course, we can import math before importing arraymancer which solves the problem.

@Vindaar
Copy link
Collaborator

Vindaar commented Feb 20, 2021

As mentioned in the PR, the problem is that ^ is at least nowadays part of math, which was not imported in the least squares lapack helper file.

Vindaar added a commit that referenced this issue Feb 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants