Imran Younus created SYSTEMML-1167:
--------------------------------------

             Summary: problem with matrix indexing
                 Key: SYSTEMML-1167
                 URL: https://issues.apache.org/jira/browse/SYSTEMML-1167
             Project: SystemML
          Issue Type: Bug
          Components: Compiler, Runtime
            Reporter: Imran Younus


I've created a recursive QR decomposition algorithm (see 
https://github.com/apache/incubator-systemml/pull/322). As part of this 
algorithm I've implemented a function that converts householder matrix to Q:

{code}
QfromH = function(Matrix[double] H)
  return(Matrix[double] Q) {
    m = nrow(H);
    n = ncol(H);
    ones = matrix(1, m, 1);
    eye = diag(ones);
    Q = eye[,1:n];

    for (j in n:1) {
      v = H[j:m,j]
      b = as.scalar(2/(t(v) %*% v))
      Q[j:m, j:n] = Q[j:m, j:n] - (b * v) %*% (t(v) %*% Q[j:m, j:n])
    }
}
{code}

In this code, I'm initializing {{Q}} from {{eye\[,1:n\]}}. So {{Q}} should be a 
{{m x n}} matrix with {{m > n}}. This function is called in the base case for 
the recursive QR algorithm.

At the first call, the matrix {{Q}} has correct shape. But, in every successive 
call it become a {{m x m}} matrix instead of {{m x n}} matrix and the algorithm 
breaks down.

It turns out that if the compiler optimization level is set to 0, then this 
problem goes away. Please see the discussion at 
https://github.com/apache/incubator-systemml/pull/322




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

Reply via email to