You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@systemml.apache.org by "Deron Eriksson (JIRA)" <ji...@apache.org> on 2016/05/23 21:08:12 UTC

[jira] [Created] (SYSTEMML-707) diag not generate square matrix if given Nx1 matrix of zeroes

Deron Eriksson created SYSTEMML-707:
---------------------------------------

             Summary: diag not generate square matrix if given Nx1 matrix of zeroes
                 Key: SYSTEMML-707
                 URL: https://issues.apache.org/jira/browse/SYSTEMML-707
             Project: SystemML
          Issue Type: Bug
          Components: APIs
            Reporter: Deron Eriksson


Thank you Matthew Plourde for finding this!

If an Nx1 matrix of 0's is given to the diag() function, an Nx1 matrix of 0's is returned. However, if an Nx1 matrix consists of any values that aren't 0's, an NxN diagonal matrix is returned. This is inconsistent and the Nx1 matrix of 0's to diag() should probably return an NxN matrix.

Example 1:
{code}
zeroes=matrix(0, 5, 1);
print(toString(zeroes));
print(toString(diag(zeroes)));
{code}
gives:
{code}
0.000
0.000
0.000
0.000
0.000

0.000
0.000
0.000
0.000
0.000
{code}

Example 2:
{code}
ones=matrix(1, 5, 1);
print(toString(ones));
print(toString(diag(ones)));
{code}
gives:
{code}
1.000
1.000
1.000
1.000
1.000

1.000 0.000 0.000 0.000 0.000
0.000 1.000 0.000 0.000 0.000
0.000 0.000 1.000 0.000 0.000
0.000 0.000 0.000 1.000 0.000
0.000 0.000 0.000 0.000 1.000
{code}

Example 3:
{code}
nums=matrix("0 1 2 3 4", 5, 1);
print(toString(nums));
print(toString(diag(nums)));
{code}
gives:
{code}
0.000
1.000
2.000
3.000
4.000

0.000 0.000 0.000 0.000 0.000
0.000 1.000 0.000 0.000 0.000
0.000 0.000 2.000 0.000 0.000
0.000 0.000 0.000 3.000 0.000
0.000 0.000 0.000 0.000 4.000
{code}




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)