1
- 'From Cuis 6.0 [latest update: #5202 ] on 26 May 2022 at 12:46:22 pm'!
1
+ 'From Cuis 6.0 [latest update: #5791 ] on 7 May 2023 at 6:18:48 pm'!
2
2
'Description '!
3
- !provides: 'LinearAlgebra' 1 59 !
3
+ !provides: 'LinearAlgebra' 1 60 !
4
4
SystemOrganization addCategory: 'LinearAlgebra'!
5
5
6
6
@@ -2149,15 +2149,15 @@ rowsCloserToZero: count
2149
2149
asSortedCollection: [ :a :b | a y < b y ])
2150
2150
copyFrom: 1 to: count) collect: [ : each | each x ] ) asSortedCollection! !
2151
2151
2152
- !FloatMatrix methodsFor: 'files' stamp: 'jmv 12/4/2017 14 : 59 : 32 '!
2152
+ !FloatMatrix methodsFor: 'files' stamp: 'jmv 5/7/2023 11 : 00 : 59 '!
2153
2153
readFromNpyStream : byteStream bigEndian: isByteStreamBigEndian
2154
2154
| bytesPerElement rowBytes |
2155
- bytesPerElement _ 4.
2156
- rowBytes _ ByteArray new: width*bytesPerElement.
2155
+ bytesPerElement : = 4.
2156
+ rowBytes : = ByteArray new: width*bytesPerElement.
2157
2157
1 to: height do: [ : i |
2158
2158
byteStream nextInto: rowBytes.
2159
2159
1 to: width do: [ : j |
2160
- self i: i j: j put: (rowBytes floatAt : j-1*bytesPerElement+1 bigEndian: isByteStreamBigEndian) ]].! !
2160
+ self i: i j: j put: (rowBytes float32At : j-1*bytesPerElement+1 bigEndian: isByteStreamBigEndian) ]].! !
2161
2161
2162
2162
!FloatMatrix methodsFor: 'operations' stamp: 'jmv 9/2/2014 11: 28'!
2163
2163
round
@@ -2219,7 +2219,7 @@ fromNpyFile: aFileEntry
2219
2219
stream binary.
2220
2220
self fromNpyStream: stream ]! !
2221
2221
2222
- !FloatMatrix class methodsFor: 'files' stamp: 'jmv 5/26/2022 12 : 18 : 26 '!
2222
+ !FloatMatrix class methodsFor: 'files' stamp: 'jmv 5/7/2023 11 : 07 : 25 '!
2223
2223
fromNpyStream : byteStream
2224
2224
"
2225
2225
FloatMatrix fromNpyFile: 'vigneteo' asDirectoryEntry // 'vign_x.npy'
@@ -2228,15 +2228,15 @@ self asForm writeJPEGfileNamed: 'tt.jpg'.
2228
2228
(self asFormMin : 0.0 max : 1.0 ) writeJPEGfileNamed: 'ttt.jpg'.
2229
2229
"
2230
2230
| magic hLength versionMajor versionMinor headerData i1 i2 key descrString fortranOrderString columnsString rowsString answer height instanceClass isBigEndian width bytesPerElement |
2231
- magic _ byteStream next: 6.
2231
+ magic : = byteStream next: 6.
2232
2232
self assert: magic = (#[16r93], 'NUMPY' asByteArray).
2233
- versionMajor _ byteStream next.
2234
- versionMinor _ byteStream next.
2233
+ versionMajor : = byteStream next.
2234
+ versionMinor : = byteStream next.
2235
2235
versionMajor caseOf: {
2236
- [1 ] - > [hLength _ (byteStream next : 2 ) unsignedShortAt : 1 bigEndian : false ].
2237
- [2 ] - > [hLength _ (byteStream next : 4 ) unsignedShortAt : 1 bigEndian : false ].
2236
+ [1 ] - > [hLength := (byteStream next : 2 ) uint16At : 1 bigEndian : false ].
2237
+ [2 ] - > [hLength := (byteStream next : 4 ) uint16At : 1 bigEndian : false ].
2238
2238
} otherwise: [ self error: 'Unsupported format' ].
2239
- headerData _ String fromUtf8Bytes: (byteStream next: hLength). " It is ASCII. utf-8 will do."
2239
+ headerData : = String fromUtf8Bytes: (byteStream next: hLength). " It is ASCII. utf-8 will do."
2240
2240
2241
2241
" Read 'an ASCII string which contains a Python literal expression of a dictionary'
2242
2242
https: //docs.scipy.org/doc/numpy-dev/neps/npy-format.html
@@ -2247,41 +2247,41 @@ self asForm writeJPEGfileNamed: 'tt.jpg'.
2247
2247
'no fortran order, i.e. row-major, i.e. row after row'
2248
2248
'major size (i.e. rows)= 5120. minor size (i.e. columns) = 5120
2249
2249
"
2250
- i1 _ 1.
2251
- key _ '''descr'''.
2252
- i1 _ (headerData findString: key startingAt: i1) + key size.
2253
- i1 _ headerData findString: $' asString startingAt: i1.
2254
- i1 _ i1 + 1.
2255
- i2 _ headerData findString: $' asString startingAt: i1.
2256
- descrString _ headerData copyFrom: i1 to: i2-1.
2257
-
2258
- key _ '''fortran_order'''.
2259
- i1 _ (headerData findString: key startingAt: i1) + key size.
2260
- i1 _ headerData findString: $: asString startingAt: i1.
2261
- i1 _ i1 + 1.
2262
- i2 _ headerData findString: $, asString startingAt: i1.
2263
- fortranOrderString _ (headerData copyFrom: i1 to: i2-1) withBlanksTrimmed.
2264
-
2265
- key _ '''shape'''.
2266
- i1 _ (headerData findString: key startingAt: i1) + key size.
2267
- i1 _ headerData findString: $( asString startingAt: i1.
2268
- i1 _ i1 + 1.
2269
- i2 _ headerData findString: $, asString startingAt: i1.
2270
- rowsString _ (headerData copyFrom: i1 to: i2-1) withBlanksTrimmed.
2271
- i1 _ i2 + 1.
2272
- i2 _ headerData findString: $) asString startingAt: i1.
2273
- columnsString _ (headerData copyFrom: i1 to: i2-1) withBlanksTrimmed.
2274
-
2275
- isBigEndian _ descrString first = $> .
2250
+ i1 : = 1.
2251
+ key : = '''descr'''.
2252
+ i1 : = (headerData findString: key startingAt: i1) + key size.
2253
+ i1 : = headerData findString: $' asString startingAt: i1.
2254
+ i1 : = i1 + 1.
2255
+ i2 : = headerData findString: $' asString startingAt: i1.
2256
+ descrString : = headerData copyFrom: i1 to: i2-1.
2257
+
2258
+ key : = '''fortran_order'''.
2259
+ i1 : = (headerData findString: key startingAt: i1) + key size.
2260
+ i1 : = headerData findString: $: asString startingAt: i1.
2261
+ i1 : = i1 + 1.
2262
+ i2 : = headerData findString: $, asString startingAt: i1.
2263
+ fortranOrderString : = (headerData copyFrom: i1 to: i2-1) withBlanksTrimmed.
2264
+
2265
+ key : = '''shape'''.
2266
+ i1 : = (headerData findString: key startingAt: i1) + key size.
2267
+ i1 : = headerData findString: $( asString startingAt: i1.
2268
+ i1 : = i1 + 1.
2269
+ i2 : = headerData findString: $, asString startingAt: i1.
2270
+ rowsString : = (headerData copyFrom: i1 to: i2-1) withBlanksTrimmed.
2271
+ i1 : = i2 + 1.
2272
+ i2 : = headerData findString: $) asString startingAt: i1.
2273
+ columnsString : = (headerData copyFrom: i1 to: i2-1) withBlanksTrimmed.
2274
+
2275
+ isBigEndian : = descrString first = $> .
2276
2276
self assert : descrString second = $f.
2277
- bytesPerElement _ descrString third digitValue.
2278
- instanceClass _ bytesPerElement caseOf : { [4 ] - > [FloatMatrix ]. [8 ] - > [Float64Matrix ]} otherwise: [self assert: false ].
2277
+ bytesPerElement := descrString third digitValue.
2278
+ instanceClass := bytesPerElement caseOf : { [4 ] - > [FloatMatrix ]. [8 ] - > [Float64Matrix ]} otherwise: [self assert: false ].
2279
2279
2280
2280
self assert: fortranOrderString = 'False'.
2281
- height _ rowsString asInteger.
2282
- width _ columnsString asInteger.
2281
+ height : = rowsString asInteger.
2282
+ width : = columnsString asInteger.
2283
2283
2284
- answer _ instanceClass height: height width: width.
2284
+ answer : = instanceClass height: height width: width.
2285
2285
answer readFromNpyStream: byteStream bigEndian: isBigEndian.
2286
2286
2287
2287
^ answer! !
@@ -2354,7 +2354,7 @@ true ifTrue: [ ^ super j: j put: column ].
2354
2354
1 to: height do: [ : i |
2355
2355
self i: i j: j put: (column at: i) ]! !
2356
2356
2357
- !Float64Matrix methodsFor: 'files' stamp: 'jmv 12/4/2017 15 : 09 : 52 '!
2357
+ !Float64Matrix methodsFor: 'files' stamp: 'jmv 5/7/2023 10 : 54 : 09 '!
2358
2358
readFromNpyStream : byteStream bigEndian: isByteStreamBigEndian
2359
2359
"
2360
2360
FloatMatrix fromNpyFile: 'vigneteo' asDirectoryEntry // 'vign_x.npy'
@@ -2366,12 +2366,12 @@ readFromNpyStream: byteStream bigEndian: isByteStreamBigEndian
2366
2366
isByteStreamBigEndian | Smalltalk isBigEndian ifFalse: [
2367
2367
^ self readFromNpyStreamFastHack: byteStream ].
2368
2368
2369
- bytesPerElement _ 8.
2370
- rowBytes _ ByteArray new: width*bytesPerElement.
2369
+ bytesPerElement : = 8.
2370
+ rowBytes : = ByteArray new: width*bytesPerElement.
2371
2371
1 to: height do: [ : i |
2372
2372
byteStream nextInto: rowBytes.
2373
2373
1 to: width do: [ : j |
2374
- self i: i j: j put: (rowBytes doubleAt : j-1*bytesPerElement+1 bigEndian: isByteStreamBigEndian) ]]! !
2374
+ self i: i j: j put: (rowBytes float64At : j-1*bytesPerElement+1 bigEndian: isByteStreamBigEndian) ]]! !
2375
2375
2376
2376
!Float64Matrix methodsFor: 'files' stamp: 'jmv 12/4/2017 15: 07: 09'!
2377
2377
readFromNpyStreamFastHack : byteStream
0 commit comments