octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sparse(i, j, v) for N-dim input


From: David Bateman
Subject: Re: sparse(i, j, v) for N-dim input
Date: Fri, 16 May 2008 11:26:31 +0200
User-agent: Thunderbird 1.5.0.7 (Windows/20060909)

Kim Hansen wrote:
On Thu, May 15, 2008 at 6:25 PM, dbateman <address@hidden> wrote:
Kim Hansen-5 wrote:
How about making
  S = sparse (I, J, SV, M, N, NZMAX)
work for multi dimensional I, J and SV ?

The workaround sparse(I(:), J(:), SV(:)) is easy, but I would like
sparse() to check that the dimensions of I, J, and SV were the same
and then create the sparse matrix also for 3+-dimensional input
matrices.

I'm no sure I understand what you mean. If the size of the matrix is

I'll try with an example:

octave:1> a=reshape(1:8,[2 2 2]);
octave:2> sparse(a,a,a,8,8)
error: invalid conversion of NDArray to Matrix
error: invalid conversion of NDArray to Matrix
error: invalid conversion of NDArray to Matrix
octave:2> sparse(a(:),a(:),a(:),8,8)
ans =

Compressed Column Sparse (rows = 8, cols = 8, nnz = 8)

  (1, 1) ->  1
  (2, 2) ->  2
  (3, 3) ->  3
  (4, 4) ->  4
  (5, 5) ->  5
  (6, 6) ->  6
  (7, 7) ->  7
  (8, 8) ->  8

octave:3>

I just think that statement number 2 should work and return the same
as the 3rd statement.


Sure why not. Then in that case its a fairly small change to src/DLD-FUNCTIONS/sparse.cc that is needed.

D.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]