Numpy implements linalg.det by going through LAPACK, which only knows about
f4, f8, c8, and c16 data types.

Your request amounts to wanting an `O` dtype implementation. I think this
is a totally reasonable request as we already have such an implementation
for `np.matmul`; but it won't be particularly easy to implement or fast,
especially as it won't be optimized for fractions specifically.

Some other options for you would be to:

* use sympy's matrix operations; fractions are really just "symbolics lite"
* Extract a common denominator from your matrix, convert the numerators to
float64, and hope you don't exceed 2**52 in the result.

You could improve the second option a little by implementing (and PRing) an
integer loop for `det`, which would be somewhat easier than implementing
the object loop.

Eric


On Sun, May 16, 2021, 10:14 Shashwat Jaiswal <shashwatjaiswal2...@gmail.com>
wrote:

> How about having linalg.det returning a fraction object when passed a
> numpy matrix of fractions?
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion

Reply via email to