File tree 1 file changed +30
-1
lines changed
1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -172,7 +172,7 @@ module CrystalEdge
172
172
h.times do |c |
173
173
cell = T .new 0
174
174
width.times do |o |
175
- cell += self [o,c] * other[r, o]
175
+ cell += self [o, c] * other[r, o]
176
176
end
177
177
result[r, c] = cell
178
178
end
@@ -299,6 +299,35 @@ module CrystalEdge
299
299
def {{key}}! (* values )
300
300
copy_from {{key}}(* values)
301
301
end
302
+
303
+ # Return string representation of the matrix
304
+ def to_s
305
+ # Format matrix by taking longest number
306
+ longer = 0
307
+ W .times do |row |
308
+ H .times do |col |
309
+ if longer < " #{ @matrix [index(row, col)]} " .size
310
+ longer = " #{ @matrix [index(row, col)]} " .size
311
+ end
312
+ end
313
+ end
314
+ # Printing matrix
315
+ W .times do |row |
316
+ str = " | "
317
+ H .times do |col |
318
+ if col != H - 1
319
+ str += " #{ @matrix [index(row, col)]} "
320
+ else
321
+ str += " #{ @matrix [index(row, col)]} "
322
+ end
323
+ (longer - " #{ @matrix [index(row, col)]} " .size).times do
324
+ str += " "
325
+ end
326
+ end
327
+ str += " |"
328
+ return str
329
+ end
330
+ end
302
331
{% end % }
303
332
end
304
333
You can’t perform that action at this time.
0 commit comments