Le jeu. 16 mai 2024 à 02:36, Waldek Hebisch <[email protected]> a écrit :
>
> On Thu, May 16, 2024 at 02:09:21AM +0200, Grégory Vanuxem wrote:
> > Hello Waldek,
> >
> > Exactly what I was looking for. Thanks.
> >
> > I thought only integer based indexing was allowed, and since Record is
> > a FriCAS primitive I thought indexing by Symbol, or whatever, was not
> > possible.
>
> Note that hash tables have keys which can be of type Symbol,
> so "indexing" is easy.  But if different symbols need different code,
> than user would need to implement appropriate runtime dispatch.
> 'setelt!' can be overloaded, and that is used to invoke different code
> for each selector.
>
> If you want to use 'a.type := x' declare 'setelt' like:
>
>    setelt! : (%, "type", N) -> N
>
> Matching 'elt' would be:
>
>    elt : (%, "type") -> N

I have seen that now. And the "quick" versions are not used. That's
very handy. In fact, again with Julia, this is just to be a little
more complete with usual returned values from Julia, I just added
access to properties/fields of Julia objects:

(35) -> a:=nrand(4,4)

   (35)   -1.42136    -1.742      0.979898  -0.48064
          -0.0343245   0.602809   1.58283   -0.859754
          -2.6258     -1.35866    1.83935    0.420829
           1.71514    -0.529176  -1.43319    0.578933
                                                     Type: JuliaFloat64Matrix
                                                               Time: 0.01 sec
(36) -> svd:=jlApply("svd", nrand(4,4)::JOBJECT)

   (36)
   SVD{Float64, Float64, Matrix{Float64}, Vector{Float64}}
   U factor:
   4×4 Matrix{Float64}:
     0.417831  -0.57559   -0.400583  -0.577622
     0.866547   0.270253   0.413597   0.0706958
    -0.138286   0.653413  -0.01002   -0.744196
     0.235353   0.410745  -0.817539   0.327913
   singular values:
   4-element Vector{Float64}:
    3.088850520328464
    1.3640765718602572
    0.3053658244498711
    0.08269730187774406
   Vt factor:
   4×4 Matrix{Float64}:
    0.143299   0.562979   -0.73529    -0.349096
    0.903295  -0.0780267  -0.0803261   0.414148
    0.120522  -0.792531   -0.354939   -0.481027
    0.386003   0.221045    0.571764   -0.689367
                                                            Type: JuliaObject
                                                   Time: 0.02 (EV) = 0.03 sec
(38) -> jlApply("*", svd.U, jlApply("transpose", (svd.U)))

   (38)
   4×4 Matrix{Float64}:
     1.0          -6.36168e-18   1.47838e-16  -4.17e-18
    -6.36168e-18   1.0           1.52234e-16  -8.99941e-17
     1.47838e-16   1.52234e-16   1.0          -2.40414e-16
    -4.17e-18     -8.99941e-17  -2.40414e-16   1.0
                                                            Type: JuliaObject
                                                               Time: 0.01 sec

-- 
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/CAHnU2dYLYvziA_JySeLahLjnnJb6QsgksAu8VOmRyfz55HegBA%40mail.gmail.com.

Reply via email to