Skip to content

Commit

Permalink
Fix "expression 'arg[0]' is immutable, not 'var'"
Browse files Browse the repository at this point in the history
Code to fix the issue was provided by @Vindaar.
  • Loading branch information
AngelEzquerraAtKeysight committed Oct 6, 2023
1 parent ce9b133 commit 6d6efd7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/arraymancer/linear_algebra/helpers/decomposition_lapack.nim
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,22 @@ import std / [math, complex]
type
SupportedDecomposition* = SomeFloat | Complex64 | Complex32

template address*(x: typed): untyped =
when (NimMajor, NimMinor, NimPatch) < (1, 9, 0):
unsafeAddr(x)
else:
addr(x)

proc dataPointerMaybeCast[T](arg: Tensor[T]): auto =
when T is SomeFloat: arg.get_data_ptr
elif T is Complex32: cast[ptr lapack_complex_float](arg.get_data_ptr)
elif T is Complex64: cast[ptr lapack_complex_double](arg.get_data_ptr)
else: {.error: "Invalid type: " & $T.}

proc dataPointerMaybeCast[T](arg: seq[T]): auto =
when T is SomeFloat: arg[0].addr
elif T is Complex32: cast[ptr lapack_complex_float](arg[0].addr)
elif T is Complex64: cast[ptr lapack_complex_double](arg[0].addr)
when T is SomeFloat: address(arg[0])
elif T is Complex32: cast[ptr lapack_complex_float](address(arg[0]))
elif T is Complex64: cast[ptr lapack_complex_double](address(arg[0]))
else: {.error: "Invalid type: " & $T.}

overload(syevr, ssyevr)
Expand Down

0 comments on commit 6d6efd7

Please sign in to comment.