Matrix error

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Matrix error

Offray
Hi,

I was testing the code here:

=[1]=========

| medMatrix   |
medMatrix := Matrix new.
medMatrix
     numberOfColumns: 7;
     numberOfRows: 5.

1 to: medMatrix numberOfRows do: [:row |
     1 to: medMatrix numberOfColumns do: [ :column |
         "medMatrix at: row at: column  put: 0."
         Transcript show: row asString, ',', column asString, '|'.
     ].
     Transcript show: cr.
].
medMatrix.

===========

and I got a transcript like this:

=[2]==========
1,1|1,2|1,3|1,4|1,5|1,6|1,7|nil2,1|2,2|2,3|2,4|2,5|2,6|2,7|nil3,1|3,2|3,3|3,4|3,5|3,6|3,7|nil4,1|4,2|4,3|4,4|4,5|4,6|4,7|nil5,1|5,2|5,3|5,4|5,5|5,6|5,7|nil'[Spotter]
Exception while collecting processors for <Matrix>: Error: Instances of
UndefinedObject are not indexable'
'[Spotter] Exception while collecting processors for <Matrix>: Error:
Instances of UndefinedObject are not indexable'
'[Spotter] Exception while collecting processors for <Matrix>: Error:
Instances of UndefinedObject are not indexable'
'[Spotter] Exception while collecting processors for <Matrix>: Error:
Instances of UndefinedObject are not indexable'
=============

I tried also with SciSmalltalk matrix, but they seem to be only square ones.

What's is the problem with matrices? Why I'm getting Undefined Objects
while trying to iterate or populate them?

Thanks,

Offray

Reply | Threaded
Open this post in threaded view
|

Re: Matrix error

Offray
Hi,

I made an small matrix implementation. Nothing fancy. Just an array of
arrays and is working. Just curious now about the error message.

Cheers,

Offray

On 23/10/15 19:56, Offray Vladimir Luna Cárdenas wrote:

> Hi,
>
> I was testing the code here:
>
> =[1]=========
>
> | medMatrix   |
> medMatrix := Matrix new.
> medMatrix
>     numberOfColumns: 7;
>     numberOfRows: 5.
>
> 1 to: medMatrix numberOfRows do: [:row |
>     1 to: medMatrix numberOfColumns do: [ :column |
>         "medMatrix at: row at: column  put: 0."
>         Transcript show: row asString, ',', column asString, '|'.
>     ].
>     Transcript show: cr.
> ].
> medMatrix.
>
> ===========
>
> and I got a transcript like this:
>
> =[2]==========
> 1,1|1,2|1,3|1,4|1,5|1,6|1,7|nil2,1|2,2|2,3|2,4|2,5|2,6|2,7|nil3,1|3,2|3,3|3,4|3,5|3,6|3,7|nil4,1|4,2|4,3|4,4|4,5|4,6|4,7|nil5,1|5,2|5,3|5,4|5,5|5,6|5,7|nil'[Spotter]
> Exception while collecting processors for <Matrix>: Error: Instances
> of UndefinedObject are not indexable'
> '[Spotter] Exception while collecting processors for <Matrix>: Error:
> Instances of UndefinedObject are not indexable'
> '[Spotter] Exception while collecting processors for <Matrix>: Error:
> Instances of UndefinedObject are not indexable'
> '[Spotter] Exception while collecting processors for <Matrix>: Error:
> Instances of UndefinedObject are not indexable'
> =============
>
> I tried also with SciSmalltalk matrix, but they seem to be only square
> ones.
>
> What's is the problem with matrices? Why I'm getting Undefined Objects
> while trying to iterate or populate them?
>
> Thanks,
>
> Offray
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Matrix error

wernerk
Hi Offray,
you could try this:

medMatrix:=Matrix rows: 5 columns: 7.
1 to: medMatrix numberOfRows do: [:row |
     1 to: medMatrix numberOfColumns do: [ :column |
         medMatrix at: row at: column  put: 0.
         Transcript show: row asString, ',', column asString, '|'.
     ].
     Transcript  cr.
]."see transcript"
medMatrix.
"(0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0 )"
"in scismalltalk:"
m2:=DhbMatrix rows: ((1 to: 5) collect:[:i|(Array new:7)]).
1 to: m2 numberOfRows do: [:row |
     1 to: m2 numberOfColumns do: [ :column |
         m2 at: row at: column  put: 0.
         Transcript show: row asString, ',', column asString, '|'.
     ].
     Transcript  cr.
]."see transcript"
m2.
"a DhbVector(0 0 0 0 0 0 0)
a DhbVector(0 0 0 0 0 0 0)
a DhbVector(0 0 0 0 0 0 0)
a DhbVector(0 0 0 0 0 0 0)
a DhbVector(0 0 0 0 0 0 0)"


werner

Reply | Threaded
Open this post in threaded view
|

Re: Matrix error

Offray
Thanks Werner,

Both work fine. First seems more legible to me and I don't need
DhbVector properties yet. My error was using #numberOfRows
#numberOfColumns as constructors instead of #rows and #columns.

Cheers,

Offray

On 24/10/15 03:21, Werner Kassens wrote:

> Hi Offray,
> you could try this:
>
> medMatrix:=Matrix rows: 5 columns: 7.
> 1 to: medMatrix numberOfRows do: [:row |
>     1 to: medMatrix numberOfColumns do: [ :column |
>         medMatrix at: row at: column  put: 0.
>         Transcript show: row asString, ',', column asString, '|'.
>     ].
>     Transcript  cr.
> ]."see transcript"
> medMatrix.
> "(0 0 0 0 0 0 0
> 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 )"
> "in scismalltalk:"
> m2:=DhbMatrix rows: ((1 to: 5) collect:[:i|(Array new:7)]).
> 1 to: m2 numberOfRows do: [:row |
>     1 to: m2 numberOfColumns do: [ :column |
>         m2 at: row at: column  put: 0.
>         Transcript show: row asString, ',', column asString, '|'.
>     ].
>     Transcript  cr.
> ]."see transcript"
> m2.
> "a DhbVector(0 0 0 0 0 0 0)
> a DhbVector(0 0 0 0 0 0 0)
> a DhbVector(0 0 0 0 0 0 0)
> a DhbVector(0 0 0 0 0 0 0)
> a DhbVector(0 0 0 0 0 0 0)"
>
>
> werner
>
>