363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
|
# File 'lib/rmatrix/matrix.rb', line 363
def condensed(sz=10, sig=6, vdots='\\vdots', cdots='\\cdots', ddots='\\ddots')
width = [sz, self.cols].min
height = [sz, self.rows].min
insert_cdots = self.cols > sz
insert_vdots = self.rows > sz
width += 1 if insert_cdots
height += 1 if insert_vdots
blank = M.blank(rows: height, columns: width, typecode: Typecode::OBJECT)
blank.narray[0...width, 0...height] = self.narray[0...width, 0...height]
blank.narray[0...width, -1] = self.narray[0...width, -1]
blank.narray[-1,0...height] = self.narray[-1, 0...height]
blank.narray[0...width, -2] = vdots if insert_vdots
blank.narray[-2, 0...height] = cdots if insert_cdots
if insert_cdots && insert_vdots
blank.narray[-2, -2] = ddots
blank.narray[-1, -2] = vdots
blank.narray[-2, -1] = cdots
blank.narray[-1, -1] = self.narray[-1, -1]
end
blank.narray.to_a.map{|line| (sig ? Array(line).map{|v| Numeric === v ? to_significant_figures(v,sig) : v } : Array(line))}
end
|