Reduced row echelon form: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: whitespace) |
m (ws/minor fixes) |
||
Line 40: | Line 40: | ||
=={{header|Ada}}== |
=={{header|Ada}}== |
||
matrices.ads: |
matrices.ads: |
||
<lang Ada>generic |
<lang Ada>generic |
||
Line 168: | Line 167: | ||
=={{header|ALGOL 68}}== |
=={{header|ALGOL 68}}== |
||
{{trans|Python}} |
{{trans|Python}} |
||
{{works with|ALGOL 68|Standard - no extensions to language used}} |
{{works with|ALGOL 68|Standard - no extensions to language used}} |
||
{{works with|ALGOL 68G|Any - tested with release mk15-0.8b.fc9.i386}} |
{{works with|ALGOL 68G|Any - tested with release mk15-0.8b.fc9.i386}} |
||
Line 589: | Line 587: | ||
-0 -0 1 -2 |
-0 -0 1 -2 |
||
</pre> |
</pre> |
||
=={{header|C sharp}}== |
=={{header|C sharp|C#}}== |
||
<lang csharp>using System; |
<lang csharp>using System; |
||
Line 651: | Line 650: | ||
=={{header|Common Lisp}}== |
=={{header|Common Lisp}}== |
||
Direct implementation of the pseudo-code given. |
Direct implementation of the pseudo-code given. |
||
<lang lisp>(defun convert-to-row-echelon-form (matrix) |
<lang lisp>(defun convert-to-row-echelon-form (matrix) |
||
(let* ((dimensions (array-dimensions matrix)) |
(let* ((dimensions (array-dimensions matrix)) |
||
Line 1,463: | Line 1,460: | ||
=={{header|JavaScript}}== |
=={{header|JavaScript}}== |
||
{{works with|SpiderMonkey}} for the <code>print()</code> function. |
{{works with|SpiderMonkey}} for the <code>print()</code> function. |
||
Extends the Matrix class defined at [[Matrix Transpose#JavaScript]] |
Extends the Matrix class defined at [[Matrix Transpose#JavaScript]] |
||
<lang javascript>// modifies the matrix in-place |
<lang javascript>// modifies the matrix in-place |
||
Line 1,527: | Line 1,523: | ||
0,1,0,1.666666666666667 |
0,1,0,1.666666666666667 |
||
0,0,1,1</pre> |
0,0,1,1</pre> |
||
=={{header|Lua}}== |
=={{header|Lua}}== |
||
<lang lua>function ToReducedRowEchelonForm ( M ) |
<lang lua>function ToReducedRowEchelonForm ( M ) |
||
Line 1,771: | Line 1,768: | ||
=={{header|Octave}}== |
=={{header|Octave}}== |
||
<lang octave>A = [ 1, 2, -1, -4; 2, 3, -1, -11; -2, 0, -3, 22]; |
<lang octave>A = [ 1, 2, -1, -4; 2, 3, -1, -11; -2, 0, -3, 22]; |
||
refA = rref(A); |
refA = rref(A); |
||
Line 1,795: | Line 1,791: | ||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
{{trans|Python}} |
{{trans|Python}} |
||
Note that the function defined here takes an array reference, not an array. |
Note that the function defined here takes an array reference, not an array. |
||
<lang perl>sub rref |
<lang perl>sub rref |
||
Line 1,825: | Line 1,820: | ||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |
||
{{trans|Perl}} |
{{trans|Perl}} |
||
{{works with|Rakudo|2010.12}} |
{{works with|Rakudo|2010.12}} |
||
<lang perl6>sub rref (@m is rw) { |
<lang perl6>sub rref (@m is rw) { |
||
@m or return; |
@m or return; |
||
Line 2,083: | Line 2,076: | ||
=={{header|PHP}}== |
=={{header|PHP}}== |
||
{{works with|PHP|5.x |
{{works with|PHP|5.x}} |
||
{{trans|Java}} |
|||
<lang php><?php |
<lang php><?php |
||
Line 2,165: | Line 2,157: | ||
=={{header|Python}}== |
=={{header|Python}}== |
||
This closely follows the pseudocode given. If you want accurate results, use the fractions package. |
This closely follows the pseudocode given. If you want accurate results, use the fractions package. |
||
<lang python>def ToReducedRowEchelonForm( M): |
<lang python>def ToReducedRowEchelonForm( M): |
||
if not M: return |
if not M: return |
||
Line 2,237: | Line 2,228: | ||
print(m) |
print(m) |
||
print(rref(m))</lang> |
print(rref(m))</lang> |
||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
Line 2,422: | Line 2,412: | ||
0.0 1.0 0.0 1.66666666666667 |
0.0 1.0 0.0 1.66666666666667 |
||
0.0 0.0 1.0 1.0</pre> |
0.0 0.0 1.0 1.0</pre> |
||
=={{header|Sage}}== |
=={{header|Sage}}== |
||
{{works with|Sage|4.6.2}} |
{{works with|Sage|4.6.2}} |
||
Line 2,607: | Line 2,598: | ||
=={{header|TI-89 BASIC}}== |
=={{header|TI-89 BASIC}}== |
||
<lang ti89b>rref([1,2,–1,–4; 2,3,–1,–11; –2,0,–3,22])</lang> |
<lang ti89b>rref([1,2,–1,–4; 2,3,–1,–11; –2,0,–3,22])</lang> |
||