File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -3241,6 +3241,34 @@ cdef class DenseMatrixBase(MatrixBase):
3241
3241
def __str__ (self ):
3242
3242
return deref(self .thisptr).__str__().decode(" utf-8" )
3243
3243
3244
+ def _repr_latex_ (self ):
3245
+ MAX_NUMBER_OF_ROWS = 24
3246
+ MAX_NUMBER_OF_COLUMNS = 16
3247
+
3248
+ values = list (self )
3249
+ ncols= self .shape[1 ]
3250
+ nrows = self .shape[0 ]
3251
+ if nrows > MAX_NUMBER_OF_ROWS:
3252
+ nrows_display = MAX_NUMBER_OF_ROWS - 2
3253
+ else :
3254
+ nrows_display= nrows
3255
+ ncols_display = min (ncols, MAX_NUMBER_OF_COLUMNS)
3256
+ latex = r ' $ \d isplaystyle \l eft[\b egin{matrix}'
3257
+
3258
+ newline = r' \\ '
3259
+ if ncols_display<ncols:
3260
+ newline = ' & \c dots ' + newline
3261
+ for row in range(nrows_display):
3262
+ vv = values[row*ncols:(row*ncols)+ncols_display ]
3263
+ latex += ' & ' .join([str (v) for v in vv])
3264
+ if row < self .shape[0 ]- 1 :
3265
+ latex += newline
3266
+ if nrows_display < nrows:
3267
+ latex += ' & ' .join([r ' \v dots' for v in vv])
3268
+
3269
+ latex += r ' \e nd{matrix}\r ight]$ '
3270
+ return latex
3271
+
3244
3272
def __add__ (a , b ):
3245
3273
a = _sympify(a, False )
3246
3274
b = _sympify(b, False )
You can’t perform that action at this time.
0 commit comments