Creating an operator

8 views
Skip to first unread message

Grégory Vanuxem

unread,
Feb 25, 2026, 1:16:27 PM (4 days ago) Feb 25
to fricas...@googlegroups.com
Hello,

Consider this:

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

(1)

-0.863933 0.621559 -1.32229 -0.890806
-0.612494 -1.59226 1.98657 -0.269779
0.747213 0.700417 0.44448 -1.22057
0.540618 0.445654 -0.694296 1.52915
Type: JLFloat64Matrix
Time: 0 sec
(2) -> a(1,3)

(2) -1.3222918354742483
Type: JLFloat64
Time: 0 sec

It is an "automatic" indexing operator acting like a function if I can
think like this. In fact, as this as a model, I would like to know if
it is possible to have a defined function operator like (the first
one):

(3) -> f(x)==x/7
Type: Void
Time: 0 sec
-- f(3) => 3/7

(4) -> f:=jfunc f
Function definition for f is being overwritten.

(4) f (generic function with 1 method)
Type: JLObjFunction(f)
Time: 0.15 (EV) + 0.06 (OT) = 0.21 sec
(5) -> jlApply(f,3)

(5) 3/7
Type: JLObject
Time: 0.11 (OT) = 0.12 sec
(6) -> jlType %

(6) Rational{Int64}
Type: Symbol
Time: 0 sec

My English isn't very good, I wonder if and how if this is possible to
have the second 'f' acting like the first (so, not handled by the
interpreter). To resume, I would like to get rid of "jlApply". Is this
possible? Do I need to modify the Boot code? I try as best as I can to
not modify original FriCAS internals.

Hope I am a little clear.

Greg

Waldek Hebisch

unread,
Feb 25, 2026, 1:24:29 PM (4 days ago) Feb 25
to fricas...@googlegroups.com
On Wed, Feb 25, 2026 at 07:15:47PM +0100, Grégory Vanuxem wrote:
> Hello,
>
> Consider this:
>
> (1) -> a:=nrand(4,4)
>
> (1)
>
> -0.863933 0.621559 -1.32229 -0.890806
> -0.612494 -1.59226 1.98657 -0.269779
> 0.747213 0.700417 0.44448 -1.22057
> 0.540618 0.445654 -0.694296 1.52915
> Type: JLFloat64Matrix
> Time: 0 sec
> (2) -> a(1,3)
>
> (2) -1.3222918354742483
> Type: JLFloat64
> Time: 0 sec
>
> It is an "automatic" indexing operator acting like a function if I can
> think like this.

TwoDimensionalArrayCategory array category declares:

elt : (%, Integer, Integer) -> R

If your JLFloat64Matrix inherits from TwoDimensionalArrayCategory
and implements 'elt', then it will work as above.
Add 'elt' to your domain.

--
Waldek Hebisch

Grégory Vanuxem

unread,
Feb 25, 2026, 2:17:42 PM (4 days ago) Feb 25
to fricas...@googlegroups.com
Huh? I will try

Greg
 

Grégory Vanuxem

unread,
Feb 26, 2026, 1:57:59 AM (3 days ago) Feb 26
to fricas...@googlegroups.com
Hello Waldek,
Thanks. Good. As always ;)

Greg
Reply all
Reply to author
Forward
0 new messages