Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infinite nullspace on standalone page #12

Open
jo-pol opened this issue Jul 27, 2020 · 8 comments
Open

infinite nullspace on standalone page #12

jo-pol opened this issue Jul 27, 2020 · 8 comments

Comments

@jo-pol
Copy link

jo-pol commented Jul 27, 2020

I tried a nullspace calculation which seem to run forever in a standalone web-page. The same two JavaScript lines run quickly on https://mlweb.loria.fr/lalolab/index.html

I tried to import the script from the head section as shown below, tried also in the body, in both cases with and without the type attribute. Tried firefox and chrome. What am I missing?


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>test</title>
    <script type="application/x-javascript" src="http://mlweb.loria.fr/lalolib.js "></script>
</head>
<body>
<script>
    const data = [[0,0,0,0,0,0,0,1,0,0,0,0,1,-1,0,-1,0,-1,0,0],[0,0,0,0,0,0,1,-1,0,0,-1,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,-1],[0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,-1,1,0,0],[0,0,1,0,0,0,0,0,1,-1,0,0,-1,0,0,0,0,0,0,0],[1,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,1,0,0,0,1,1,-1,0,0,0,0,0,0,-1,0],[0,-1,0,0,0,0,0,0,0,0,0,1,0,0,-1,1,0,0,0,0],[0,0,-1,1,-1,0,-1,0,0,0,0,0,0,0,1,0,0,0,0,0],[-1,1,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,1,0,0,1],[0,0,0,0,0,0,0,0,0,1,0,0,-1,-1,0,0,0,0,1,0],[0,0,1,0,0,0,-1,-1,0,0,0,0,1,0,0,0,0,0,0,0],[0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,-1,-1],[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,-1,-1,0,1],[1,0,0,0,0,1,0,0,-1,-1,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,-1,-1,1,0,0,0,1,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,1,0,0,-1,-1,0,0,0,1,0,0,0,0],[0,0,0,1,0,0,0,0,0,0,0,0,0,0,-1,-1,0,1,0,0],[0,0,-1,-1,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0],[-1,-1,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0]];
    console.log(nullspace(array2mat(data)));
</script>
</body>
</html>
@jo-pol
Copy link
Author

jo-pol commented Jul 28, 2020

Same happens when I save a local copy of https://mlweb.loria.fr/lalolab/lalolib.html
and add the two lines to function ex1 ()

@lauerfab
Copy link
Owner

First, note that Lalolab performs all computations in a separate web worker.
You can do that in a stand-alone page by create a "Lab", see : https://mlweb.loria.fr/lalolab/lalolib.html#safer .
Otherwise, if it takes more than a few seconds a browser usually blocks the script.
However, it seems that I observe the same issue even in lalolab so far.

@jo-pol
Copy link
Author

jo-pol commented Jul 29, 2020

The weird thing is that it hardly takes any time when tried on https://mlweb.loria.fr/lalolab/index.html
So what is the essential difference with the "safer" example?

@jo-pol
Copy link
Author

jo-pol commented Sep 23, 2020

Tried again with example 2 and 3 but now I get

Security Error: Content at file:///XXX.html may not load data from http://mlweb.loria.fr/lalolibworker.js.

Tried to tweak the following code with a local copy of both .js files but I'm too unfamiliar with these things to succeed.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>test</title>
    <script type="application/x-javascript" src="http://mlweb.loria.fr/lalolib.js "></script>
</head>
<body>
<script>
    var lab = new Lalolab() ;   // open a standard Lab

	// define a variable in the current scope
	var A = [[0,0,0,0,0,0,0,1,0,0,0,0,1,-1,0,-1,0,-1,0,0],[0,0,0,0,0,0,1,-1,0,0,-1,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,-1],[0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,-1,1,0,0],[0,0,1,0,0,0,0,0,1,-1,0,0,-1,0,0,0,0,0,0,0],[1,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,1,0,0,0,1,1,-1,0,0,0,0,0,0,-1,0],[0,-1,0,0,0,0,0,0,0,0,0,1,0,0,-1,1,0,0,0,0],[0,0,-1,1,-1,0,-1,0,0,0,0,0,0,0,1,0,0,0,0,0],[-1,1,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,1,0,0,1],[0,0,0,0,0,0,0,0,0,1,0,0,-1,-1,0,0,0,0,1,0],[0,0,1,0,0,0,-1,-1,0,0,0,0,1,0,0,0,0,0,0,0],[0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,-1,-1],[0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,-1,-1,0,1],[1,0,0,0,0,1,0,0,-1,-1,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,-1,-1,1,0,0,0,1,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,1,0,0,-1,-1,0,0,0,1,0,0,0,0],[0,0,0,1,0,0,0,0,0,0,0,0,0,0,-1,-1,0,1,0,0],[0,0,-1,-1,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0],[-1,-1,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0]];

	lab.load(A, "A", function (result) {  // load the variable in the lab
		res3.innerHTML = "The matrix A = " + laloprint(result,true) + " has been loaded in the lab.<br>";
	});
	lab.do("n = nullspace(array2mat(data))");	// do some computation in the background
	lab.getObject("n", function ( result ) { // recover the value of a variable from the lab
		res3.innerHTML += "The nullspace of A is stored in the lab variable n which equals " + result;
	});	</script>
</body>
</html>

@lauerfab
Copy link
Owner

lauerfab commented Sep 24, 2020 via email

@jo-pol
Copy link
Author

jo-pol commented Sep 24, 2020

I'd like to apply these scripts on a public website. I can't and should not ask from non-tech users to circumvent security measures against cross-site scripting that way.

@jo-pol
Copy link
Author

jo-pol commented Sep 24, 2020

Let me return to the original issue. I want to do a nullspace calculation client-side by JavaScript on a public web page. The calculation runs quickly on https://mlweb.loria.fr/lalolab/index.html but takes forever when tried in example-1 on https://mlweb.loria.fr/lalolab/lalolib.html

@jo-pol
Copy link
Author

jo-pol commented Sep 25, 2020

Tried it publicly with https://github.com/jo-pol/test-lalolib/blob/master/index.html published at https://jo-pol.github.io/test-lalolib/

Now I get

Security Error: Content at https://jo-pol.github.io/test-lalolib/ may not load data from http://mlweb.loria.fr/lalolibworker.js.

Could you please replace http with https where ever applicable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants