interfacing arb, acb matrices with Julia more tightly

36 views
Skip to first unread message

Jeffrey Sarnoff

unread,
Jan 4, 2025, 7:13:12 AMJan 4
to flint-devel
with the latest Julia release, a user reports occasional failures when using ArbNumerics.jl with large complex matrices.  This is not an issue with Flint.  To resolve this and expand the functionality of arf, arb, acb vectors and matrices within ArbNumerics, I need to revisit the interoperabilities of Julia vectors/matricies with Flint's arb sublibrary.

Julia stores matrices in column order (like Fortran, unlike C).  So we want as little back and forth as possible.  What would be the most efficient way to define Julia structs to match or map over Arb vectors / matricies?  Asking in case you happen to know ... I have been copying element by element using separate memory regions.

Best,
Jeffrey
 

Albin Ahlbäck

unread,
Jan 4, 2025, 7:27:21 AMJan 4
to flint...@googlegroups.com, Jeffrey Sarnoff
Dear Jeffrey,

As you may know, Arb vectors are simply a pointer to `arb_struct`, i.e.
`arb_struct *`.

Arb matrices are defined as the following:
```
typedef struct
{
arb_ptr entries;
slong r;
slong c;
arb_ptr * rows;
}
arb_mat_struct;
```
where the `arb_struct *` to the element (i, j) in a matrix `mat` is given by
```
mat->rows[i] + j
```
in C. Note that you should not access the field `entries` (at least
currently, may be valid in the future).

Does this answer your question?

Best,
Albin
> --
>
> ---
> You received this message because you are subscribed to the Google
> Groups "flint-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to flint-devel...@googlegroups.com <mailto:flint-
> devel+un...@googlegroups.com>.
> To view this discussion, visit https://groups.google.com/d/msgid/flint-
> devel/
> CAM96OoKNrPYTYm68ruM%2Bc9pK%3DuU07QmNiH%3DTk%3DdVFS2h0_BNDg%40mail.gmail.com <https://groups.google.com/d/msgid/flint-devel/CAM96OoKNrPYTYm68ruM%2Bc9pK%3DuU07QmNiH%3DTk%3DdVFS2h0_BNDg%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Jeffrey Sarnoff

unread,
Jan 4, 2025, 7:49:43 AMJan 4
to Albin Ahlbäck, flint...@googlegroups.com
Thanks, maybe. I am using your info to investigate more.


Claus Fieker

unread,
Jan 6, 2025, 2:21:02 AMJan 6
to flint...@googlegroups.com
On Sat, Jan 04, 2025 at 07:49:05AM -0500, Jeffrey Sarnoff wrote:
> Thanks, maybe. I am using your info to investigate more.
There are limits which you cannot (easily) bypass: views, in flint, are
basically the same data type: they share the entries, adjust r & c and
use a subset of the rows with an offset. Thus a flint view has to have
consecutive columns, but may have "random" seletion of rows (ie. odd
ones only)
Further: rows can be swaped without touching entries, thus resizing is
not possible - unless no row-swap has happened. We played with this
quite a bit for the fmpz_mat(s).

In some cases (julia Vector{Int}) a translation to flint is possibly -
without time penalty
https://github.com/Nemocas/Nemo.jl/blob/master/src/flint/fmpz_mat.jl#L1797
for an evil example
In others (julia Vector{ZZRingElem} = Vector{fmpz}) this will be harder
up to impossible...

all the best of luck!
Claus
> To unsubscribe from this group and stop receiving emails from it, send an email to flint-devel...@googlegroups.com.
> To view this discussion, visit https://groups.google.com/d/msgid/flint-devel/CAM96OoJDQnyw4%2BbZroGT9vQJNUYU8gYie_HkOEjrpN_FHbBwFQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages