hermann on Fri, 24 May 2024 13:48:35 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Making use of "GP in your browser" questions


In current JSCAD project
https://hermann-sw.github.io/lattice_sphere_cmp

I needed to determine r3(n), the number of different sum of 3 squares of n.
I implemented it via a matrix computed with PARI/GP:

https://github.com/Hermann-SW/lattice_sphere_cmp/blob/main/lattice_sphere_cmp.js#L35-L49

// https://en.wikipedia.org/wiki/Sum_of_squares_function#k_=_3
// computed with PARI/GP: 12*qfbclassno(-4*p*q)
const r3 = ((p,q) => R3[P1.indexOf(p)][P1.indexOf(q)])
P1=[5, 13, 17, 29, 37, 41, 53, 61, 73, 89, 97]
R3=[[0,96,48,96,192,96,96,192,240,96,240],
[96,0,192,192,192,144,480,96,144,336,240],
[48,192,0,144,432,96,288,240,384,192,576],
[96,192,144,0,288,240,192,768,432,432,720],
[192,192,432,288,0,576,384,288,576,528,528],
[96,144,96,240,576,0,240,672,576,480,672],
[96,480,288,192,384,240,0,672,1104,288,864],
[192,96,240,768,288,672,672,0,288,912,384],
[240,144,384,432,576,576,1104,288,0,768,768],
[96,336,192,432,528,480,288,912,768,0,768],
[240,240,576,720,528,672,864,384,768,768,0]]


Then I remembered this webpage:
https://pari.math.u-bordeaux.fr/gpwasm.html

While there is plenty of documentation on the website for many aspects,
I found none for making use of wasm GP in browser.

So I did save complete webpage, and downloaded gp-sta.wasm in addition:

hermann@j4105:~/gp$ tree .
.
├── PARI_GP Development Headquarters_files
│   ├── gpjswasm
│   │   └── gp-sta.wasm
│   ├── gp-sta.js
│   ├── Logo_PARI-GP_Couleurs_L150px.png
│   └── pari.css
└── PARI_GP Development Headquarters.html

2 directories, 5 files
hermann@j4105:~/gp$

I started webserver in gp directory with "python -m http.server"
and opened "http://127.0.0.1:8000/PARI_GP%20Development%20Headquarters.html"; in browser.

But I got this error:

wasm streaming compile failed: TypeError: WebAssembly: Response has unsupported MIME type 'text/html;charset=utf-8' expected 'application/wasm'
falling back to ArrayBuffer instantiation
failed to asynchronously prepare wasm: both async and sync fetching of the wasm failed
Aborted(both async and sync fetching of the wasm failed)


Questions:
1) is there some doc on how to correctly make use of

function myevalm(s) { return Module.ccall("gp_embedded","string",["string"],[s]); }

in browser JavaScript?

2) Is it OK to use

https://pari.math.u-bordeaux.fr/gpwasm/gp-sta.wasm

in own webpages for using myevalm() ?

3) Is it OK to host gp-sta.wasm eg. locally in github.io domain from lattice_sphere_cmp repo?

4) Does the repo need to have GNU license for 3?


Regards,

Hermann.