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: Kim Hansen
Subject: Re: sparse(i, j, v) for N-dim input
Date: Fri, 16 May 2008 09:54:06 +0200

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.

-- 
Kim Hansen
Vadgårdsvej 3, 2.tv
2860 Søborg
Fastnet: 3956 2437 -- Mobil: 3091 2437



reply via email to

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