On Wed, May 24, 2023 at 07:46:58PM +0200, Grégory Vanuxem wrote:
> Hello folks,
>
> I have a little problem with function selection coded in the same package.
>
> I have a temporary LinearAlgebra package which contains routines for say
> vectors and matrices with Float64 and Complex(Float64) coefficients. See
> link below if necessary. It's temporary because it will be splitted between
> Float64 and Complex(Float64) but for now this is not the point.
>
> I need to easily/quickly create random arrays. The problem in my case is
> that FriCAS always chooses Complex(Float64) instead of Float64
> coefficients. I began to code with Float64 so that borrows me a little.
>
> To illustrate:
> Declarations:
> urand01 : NNI -> JF64VEC
> ++ urand01(n) returns a uniform(0..1) Julia vector of size n.
> urand01: (NNI, NNI) -> JF64MAT
> ++ urand01(m,n) returns a uniform(0..1) Julia matrix of size (m,n).
> urand01: (NNI, NNI) -> JCF64MAT
> ++ urand01(m,n) returns a uniform(0..1) Julia matrix of size (m,n).
> urand01 : NNI -> JCF64VEC
> ++ urand01(n) returns a uniform(0..1) Julia vector of size n.
>
> Where JF64VEC is a synonym of Float64 vectors whereas JCF64VEC
> Complex(Float64) vectors. As for matrices.
>
> So my question is how do I force FriCAS to choose the JF64* versions first
> instead of JCF64* ? I tried to modify function declarations order,
> functions definitions order, src/algebra/exposed.lsp without success. Is it
> possible? It's not a big problem, I use *@Domain to switch what I need but
> this is annoying and I would be happy to know if/how it is possible.
> Any hints?
I is not clear what you really want. Spad compiler has its own rules.
Given JF64VEC and JCF64VEC intepreter has no way to know which one
is better, so it probably uses lexicographic order. How to
force right choice:
- you already know @Domain, that good solution
- you may use different names depending on type, for example 'urand01_rv',
'urand01_cv', etc.
- do as you planned and split the package. Expose wanted part.
I wrote about idea of partial exposure: if we could control exposure
for each function, we could mark unwanted variant as unexposed.
But ATM partial exposure is just an idea (and to that not fully
baked idea).
--
Waldek Hebisch
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/fricas-devel/20230524201141.kgtajvebwxo2fyop%40fricas.math.uni.wroc.pl.