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 @@ -168,7 +168,7 @@ module CrystalEdge
168
168
h.times do |c |
169
169
cell = T .new 0
170
170
width.times do |o |
171
- cell += self [o,c] * other[r, o]
171
+ cell += self [o, c] * other[r, o]
172
172
end
173
173
result[r, c] = cell
174
174
end
@@ -295,6 +295,35 @@ module CrystalEdge
295
295
def {{key}}! (* values )
296
296
copy_from {{key}}(* values)
297
297
end
298
+
299
+ # Return string representation of the matrix
300
+ def to_s
301
+ # Format matrix by taking longest number
302
+ longer = 0
303
+ W .times do |row |
304
+ H .times do |col |
305
+ if longer < " #{ @matrix [index(row, col)]} " .size
306
+ longer = " #{ @matrix [index(row, col)]} " .size
307
+ end
308
+ end
309
+ end
310
+ # Printing matrix
311
+ W .times do |row |
312
+ str = " | "
313
+ H .times do |col |
314
+ if col != H - 1
315
+ str += " #{ @matrix [index(row, col)]} "
316
+ else
317
+ str += " #{ @matrix [index(row, col)]} "
318
+ end
319
+ (longer - " #{ @matrix [index(row, col)]} " .size).times do
320
+ str += " "
321
+ end
322
+ end
323
+ str += " |"
324
+ return str
325
+ end
326
+ end
298
327
{% end % }
299
328
end
300
329
You can’t perform that action at this time.
0 commit comments