Continued fraction/Arithmetic/G(matrix ng, continued fraction n1, continued fraction n2): Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
m (Minor correction.)
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(3 intermediate revisions by 2 users not shown)
Line 1:
{{draft task|Matrices}}
This task performs the basic mathematical functions on 2 continued fractions. This requires the full version of matrix NG:
: <math>\begin{bmatrix}
Line 6,761:
public final class ContinuedFractionArithmeticG2 {
 
public static void main(String[] aArgs) {
test("[13;5,2 7] -+ [30;7 2]", new NG( new NG8(0, 1, -1, 0, 0, 0, 0, 1), new R2cf(131, 112), new R2cf(22, 7) ),
new NG( new NG4(2, 1, 0, 2), new R2cf(22, 7) ));
test("[31;7 5, 2] +* [03;2 7]", new NG( new NG8(01, 10, 10, 0, 0, 0, 0, 1), new R2cf(113, 211), new R2cf(22, 7) ),
new NG( new NG4(2, 1, 0, 2), new R2cf(22286, 777) ));
test("[1; 5, 2] *- [3; 7]", new NG( new NG8(10, 01, 0-1, 0, 0, 0, 0, 1), new R2cf(13, 11), new R2cf(22, 7) ),
new R2cf(286-151, 77) );
test("Divide [] by [3; 7]",
test("[1;5,2] - [3;7]", new NG( new NG8(0, 1, -1, 0, 0, 0, 0, 1), new R2cf(13, 11), new R2cf(22, 7) ),
new R2cf(-151, 77) );
test("Divide [] by [3;7]",
new NG( new NG8(0, 1, 0, 0, 0, 0, 1, 0), new R2cf(22 * 22, 7 * 7), new R2cf(22,7)) );
test("([0; 3, 2] + [1; 5, 2]) * ([0; 3, 2] - [1; 5, 2])",
new NG( new NG8(1, 0, 0, 0, 0, 0, 0, 1),
new NG( new NG8(0, 1, 1, 0, 0, 0, 0, 1),
Line 6,796 ⟶ 6,795:
private static abstract class MatrixNG {
publicprotected abstract void consumeTerm();
publicprotected abstract void consumeTerm(int aN);
publicprotected abstract boolean needsTerm();
protected int configuration = 0;
Line 6,993 ⟶ 6,992:
{{ out }}
<pre>
Testing: [3; 7] + [0; 2]
3 1 1 1 4
3 1 1 1 4
 
Testing: [1; 5, 2] * [3; 7]
3 1 2 2
3 1 2 2
 
Testing: [1; 5, 2] - [3; 7]
-1 -1 -24 -1 -2
-1 -1 -24 -1 -2
 
Testing: Divide [] by [3; 7]
3 7
 
Testing: ([0; 3, 2] + [1; 5, 2]) * ([0; 3, 2] - [1; 5, 2])
-1 -3 -5 -1 -2 -1 -26 -3
-1 -3 -5 -1 -2 -1 -26 -3
Line 10,886 ⟶ 10,885:
=={{header|Wren}}==
{{trans|Kotlin}}
<syntaxhighlight lang="ecmascriptwren">class MatrixNG {
construct new() {
_cfn = 0
9,476

edits