Filter löschen
Filter löschen

How to find double output?

1 Ansicht (letzte 30 Tage)
Ammy
Ammy am 2 Mär. 2022
Kommentiert: Ammy am 2 Mär. 2022
import java.math.*;
>> p=BigInteger('11');
>> m=BigInteger('2');
>> [A,B]=m.gcd(p);
Error using java.math.BigInteger/gcd
Java methods cannot be called with multiple output arguments
How to resolve this issue? I need both A and B.
Thanking in anticipation
  7 Kommentare
Ammy
Ammy am 2 Mär. 2022
@Rik Thank you ver much!
I want to extract the following
[A,B] = gcd(m,p);
if A =1 then
a = mod(B,p)
otherwise a=0
I want to find a which depends on both A and B
Ammy
Ammy am 2 Mär. 2022
@AndresVar, thank you very much but I want to deal with both the outputs.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 2 Mär. 2022
import java.math.*;
p = BigInteger('11');
m = BigInteger('2');
A = m.gcd(p)
A = 1
B = m.modInverse(p)
B = 6
m.multiply(B).mod(p)
ans = 1
  3 Kommentare
Walter Roberson
Walter Roberson am 2 Mär. 2022
import java.math.*;
p = BigInteger('11');
m = BigInteger('2');
a = inverse(m, p)
a = 6
%cross-check
cross_check = m.multiply(a).mod(p)
cross_check = 1
function a = inverse(b, p)
import java.math.*;
A = b.gcd(p);
if A == BigInteger('1')
a = b.modInverse(p);
else
a = BigInteger('0');
end
end
Ammy
Ammy am 2 Mär. 2022
Thank you very much!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Call Java from MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by