Identity matrix: Difference between revisions
Content added Content deleted
(Identity matrix in XBasic) |
|||
Line 677: | Line 677: | ||
print "Matrix is too big to display on 80 column console" |
print "Matrix is too big to display on 80 column console" |
||
end if</syntaxhighlight> |
end if</syntaxhighlight> |
||
{{out}} |
|||
<pre>Same as FreeBASIC entry.</pre> |
|||
==={{header|XBasic}}=== |
|||
{{works with|Windows XBasic}} |
|||
{{trans|FreeBASIC}} |
|||
<syntaxhighlight lang="qbasic">PROGRAM "Identity matrix" |
|||
VERSION "0.0000" |
|||
DECLARE FUNCTION Entry () |
|||
FUNCTION Entry () |
|||
DO |
|||
n = SBYTE(INLINE$("Enter size of matrix: ")) |
|||
LOOP UNTIL n > 0 |
|||
DIM identity[n, n] '' all zero by default |
|||
' enter 1s in diagonal elements |
|||
FOR i = 1 TO n |
|||
identity[i, i] = 1 |
|||
NEXT i |
|||
' print identity matrix if n < 40 |
|||
PRINT |
|||
IF n < 40 THEN |
|||
FOR i = 1 TO n |
|||
FOR j = 1 TO n |
|||
PRINT identity[i, j]; |
|||
NEXT j |
|||
PRINT |
|||
NEXT i |
|||
ELSE |
|||
PRINT "Matrix is too big to display on 80 column console" |
|||
END IF |
|||
END FUNCTION |
|||
END PROGRAM</syntaxhighlight> |
|||
{{out}} |
{{out}} |
||
<pre>Same as FreeBASIC entry.</pre> |
<pre>Same as FreeBASIC entry.</pre> |