フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How can I fix the error in the given below program?

1 回表示 (過去 30 日間)
Manoj
Manoj 2018 年 2 月 8 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
clc;
clear all;
close all;
disp('***** y^2 = x^3 + ax + b mod p *****');
n=input('insert prime p: ');
a=input('insert coefficient a: ');
b=input('insert coefficient b: ');
x=[0:n-1];
y=[0:n-1];
figure
for i=1:n
for j=1:n
if rem((vpi(y(j))^2)-(vpi(x(i))^3)-a*(vpi(x(i)))-b,n)==0
plot(x(i),y(j),'r o');
hold on;
end
end
end
grid;
hold off;
Maximum variable size allowed by the program is exceeded.
Error in sir (line 9)
x=[0:n-1];
  3 件のコメント
Manoj
Manoj 2018 年 2 月 8 日
n=730750818665451459101842416358141509827966272589 a=361221832160941494419407229753461201862246374272 b=346937986907100912443917613080678747571038706015
Star Strider
Star Strider 2018 年 2 月 8 日
Using double-precision representation, ‘x’ would then require 5.8460e+048 bytes.

回答 (1 件)

Jan
Jan 2018 年 2 月 8 日
編集済み: Jan 2018 年 2 月 8 日
input replies a double. According to the IEEE754 standard, a double has about 15 significant digits. Therefore you cannot input "730750818665451459101842416358141509827966272589" and expect it to be stored exactly. Even using the command vpi afterwards does not reconstruct the rounded digits magically. You can insert directly:
n = 7.30750818665451e47
etc. But then the shown algorithm cannot produce a meaningful output.
In addition creating a vector 0:7.3e47 needs 7.3e47*8 Bytes. There is no computer on the earth with 5.8*10^41 GigaByte RAM. And you want to create 2 of these vectors and process them in two nested loops over all elements?!
The universe is too small for this computation. Then most likely Matlab is, too. The message
Maximum variable size allowed by the program is exceeded.
is pure understatement.

この質問は閉じられています。

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by