Matrix with two diagonals: Difference between revisions

Content added Content deleted
mNo edit summary
(→‎K: add)
Line 2,098: Line 2,098:
1 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1
1 ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ 1
</syntaxhighlight>
</syntaxhighlight>

=={{header|K}}==
K6
<syntaxhighlight lang="k">diag2: {x||x}@=:

diag2 5</syntaxhighlight>
{{out}}
<pre>(1 0 0 0 1
0 1 0 1 0
0 0 1 0 0
0 1 0 1 0
1 0 0 0 1)</pre>


=={{header|Matlab}}==
=={{header|Matlab}}==
Line 2,128: Line 2,140:
A(1:N+1:end) = 1;
A(1:N+1:end) = 1;
end</syntaxhighlight>
end</syntaxhighlight>
{{Output}}
{{out}}
<pre>
<pre>
>> diagdiag(7)
>> diagdiag(7)