# Matrix

10 messages
Open this post in threaded view
|

## Matrix

 Hi, i use Pharo-1.1-11411 and got a few questions. i looked at the comments of Matrix: it talks about Array2D but this object does not exist? it says "Element-wise matrix arithmetic works", but this is not true: while + - * functions in this way: aNumber + aMatrix, "/" does not always function: aSmallInteger / aMatrix produces an error, because aMatrix is tested with isZero. a simple fix would be to change the first program line in SmallInteger>>/ from: aNumber isZero ifTrue: [^(ZeroDivide dividend: self) signal]. to: (aNumber isNumber and: [aNumber isZero]) ifTrue: [^(ZeroDivide dividend: self) signal]. further aMatrix + aNumber and similar arithmetic dont work. but with the above fix it would work nicely with  simple implementations like this: Collection>>/ / aNumber ^aNumber  adaptToCollection: self  andSend: #/ and so forth. while testing these things with Fractions, i noticed this: printing {3/4} produces this output:{(3/4)}. printing {{0.75}} produces this output:#(#(0.75)). printing {{3/4}} produces this output:{((Array new: 1) at: 1 put: (3/4); yourself)}. i wonder what the last output wants to tell me? does it want to tell me, that the last thing uses up a lot more memory than the first two, and accessing it takes more time, so that i should use the second thing instead, or is it (more or less) just print output related? werner
Open this post in threaded view
|

## Re: Matrix

 long time ago I guess there was a class Array2D which could work as a matrix. Now I do not remember if it was replaced or rewritten. Stef On Feb 2, 2011, at 9:26 PM, Werner Kassens wrote: > Hi, > i use Pharo-1.1-11411 and got a few questions. > i looked at the comments of Matrix: > > it talks about Array2D but this object does not exist? > > it says "Element-wise matrix arithmetic works", but this is not true: > while + - * functions in this way: aNumber + aMatrix, "/" does not always function: > aSmallInteger / aMatrix produces an error, because aMatrix is tested with isZero. > a simple fix would be to change the first program line in SmallInteger>>/ from: > aNumber isZero ifTrue: [^(ZeroDivide dividend: self) signal]. to: > (aNumber isNumber and: [aNumber isZero]) ifTrue: [^(ZeroDivide dividend: self) signal]. > further aMatrix + aNumber and similar arithmetic dont work. but with the above fix it would work nicely with  simple implementations like this: > Collection>>/ > / aNumber > ^aNumber  adaptToCollection: self  andSend: #/ > and so forth. > > while testing these things with Fractions, i noticed this: > printing {3/4} produces this output:{(3/4)}. > printing {{0.75}} produces this output:#(#(0.75)). > printing {{3/4}} produces this output:{((Array new: 1) at: 1 put: (3/4); yourself)}. > i wonder what the last output wants to tell me? does it want to tell me, that the last thing uses up a lot more memory than the first two, and accessing it takes more time, so that i should use the second thing instead, or is it (more or less) just print output related? > werner >
Open this post in threaded view
|

## Re: Matrix

 In reply to this post by wernerk Hi Wener, Have you tried the DhbMatrix at http://www.squeaksource.com/DHBNumerical.html ? Cheers, Hernán 2011/2/2 Werner Kassens <[hidden email]>: > Hi, > i use Pharo-1.1-11411 and got a few questions. > i looked at the comments of Matrix: > > it talks about Array2D but this object does not exist? > > it says "Element-wise matrix arithmetic works", but this is not true: > while + - * functions in this way: aNumber + aMatrix, "/" does not always > function: > aSmallInteger / aMatrix produces an error, because aMatrix is tested with > isZero. > a simple fix would be to change the first program line in SmallInteger>>/ > from: > aNumber isZero ifTrue: [^(ZeroDivide dividend: self) signal]. to: > (aNumber isNumber and: [aNumber isZero]) ifTrue: [^(ZeroDivide dividend: > self) signal]. > further aMatrix + aNumber and similar arithmetic dont work. but with the > above fix it would work nicely with  simple implementations like this: > Collection>>/ > / aNumber > ^aNumber  adaptToCollection: self  andSend: #/ > and so forth. > > while testing these things with Fractions, i noticed this: > printing {3/4} produces this output:{(3/4)}. > printing {{0.75}} produces this output:#(#(0.75)). > printing {{3/4}} produces this output:{((Array new: 1) at: 1 put: (3/4); > yourself)}. > i wonder what the last output wants to tell me? does it want to tell me, > that the last thing uses up a lot more memory than the first two, and > accessing it takes more time, so that i should use the second thing instead, > or is it (more or less) just print output related? > werner > >
Open this post in threaded view
|

## Re: Matrix

 Hi Hernán i wasn't aware of this, it is interesting indeed. thanks werner > Have you tried the DhbMatrix at http://www.squeaksource.com/DHBNumerical.html ?
Open this post in threaded view
|

## Re: Matrix

 In reply to this post by hernanmd Hi Hernán, i had a superficial look at DHBNumerical and it does indeed what i wanted to do, thanks again. i ran DHB-Numerical-Tests and it showed 5 errors.i added this method: DhbNevilleInterpolator>>initialize super initialize. leftErrors :=#(). rightErrors :=#() and the tests showed only 1 error. i havent looked, what the code does, it was only an instinctive fix, hence use with caution. the last error is not fixable in this instinctive way, one would have to understand how DhbClusterFinder actually finds clusters, and i have not yet looked at the doku and dont have the time at the moment. werner
Open this post in threaded view
|

## Re: Matrix

 Thanks Werner, I will check later with the VW image too but I've integrated your fix. I've splitted the tests to their own package. The repository is world writable so feel free to add future improvements. Hernán 2011/2/3 Werner Kassens <[hidden email]>: > Hi Hernán, > i had a superficial look at DHBNumerical and it does indeed what i wanted to > do, thanks again. > i ran DHB-Numerical-Tests and it showed 5 errors.i added this method: > DhbNevilleInterpolator>>initialize > super initialize. > leftErrors :=#(). > rightErrors :=#() > and the tests showed only 1 error. i havent looked, what the code does, it > was only an instinctive fix, hence use with caution. the last error is not > fixable in this instinctive way, one would have to understand how > DhbClusterFinder actually finds clusters, and i have not yet looked at the > doku and dont have the time at the moment. > werner > >
Open this post in threaded view
|

## Re: Matrix

 Could you add that didier agreed to release his code under MIT Tx Stef On Feb 3, 2011, at 4:43 PM, Hernán Morales Durand wrote: > Thanks Werner, I will check later with the VW image too but I've > integrated your fix. I've splitted the tests to their own package. The > repository is world writable so feel free to add future improvements. > > Hernán > > 2011/2/3 Werner Kassens <[hidden email]>: >> Hi Hernán, >> i had a superficial look at DHBNumerical and it does indeed what i wanted to >> do, thanks again. >> i ran DHB-Numerical-Tests and it showed 5 errors.i added this method: >> DhbNevilleInterpolator>>initialize >> super initialize. >> leftErrors :=#(). >> rightErrors :=#() >> and the tests showed only 1 error. i havent looked, what the code does, it >> was only an instinctive fix, hence use with caution. the last error is not >> fixable in this instinctive way, one would have to understand how >> DhbClusterFinder actually finds clusters, and i have not yet looked at the >> doku and dont have the time at the moment. >> werner >> >> >
Open this post in threaded view
|

## Re: Matrix

 It seems only Paul DeBruicker can do that, he's the project admin. Paul? 2011/2/3 Stéphane Ducasse <[hidden email]>: > Could you add that didier agreed to release his code under MIT > Tx > > Stef > > On Feb 3, 2011, at 4:43 PM, Hernán Morales Durand wrote: > >> Thanks Werner, I will check later with the VW image too but I've >> integrated your fix. I've splitted the tests to their own package. The >> repository is world writable so feel free to add future improvements. >> >> Hernán >> >> 2011/2/3 Werner Kassens <[hidden email]>: >>> Hi Hernán, >>> i had a superficial look at DHBNumerical and it does indeed what i wanted to >>> do, thanks again. >>> i ran DHB-Numerical-Tests and it showed 5 errors.i added this method: >>> DhbNevilleInterpolator>>initialize >>> super initialize. >>> leftErrors :=#(). >>> rightErrors :=#() >>> and the tests showed only 1 error. i havent looked, what the code does, it >>> was only an instinctive fix, hence use with caution. the last error is not >>> fixable in this instinctive way, one would have to understand how >>> DhbClusterFinder actually finds clusters, and i have not yet looked at the >>> doku and dont have the time at the moment. >>> werner >>> >>>