|
From: <ap...@us...> - 2025-10-08 06:23:53
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Maxima CAS".
The branch, dodier-matrix-and-box-display-flags has been created
at 3259c88b35fb60411a7fa77d6ebb576839270bf7 (commit)
- Log -----------------------------------------------------------------
commit 3259c88b35fb60411a7fa77d6ebb576839270bf7
Author: Robert Dodier <rob...@so...>
Date: Tue Oct 7 23:18:00 2025 -0700
New flag display_determinant_bars; when true, display determinant of a literal matrix with a bar on either side,
otherwise as an ordinary function call. Default is display_determinant_bars = true.
Has the advertised effect whether display2d_unicode is enabled or disabled.
diff --git a/doc/info/Matrices.texi.m4 b/doc/info/Matrices.texi.m4
index 84b42a8d3..4a4792ecc 100644
--- a/doc/info/Matrices.texi.m4
+++ b/doc/info/Matrices.texi.m4
@@ -578,12 +578,35 @@ The form of the result depends upon the setting of the switch @mrefdot{ratmx}
There is a special routine for computing sparse determinants which is called
when the switches @code{ratmx} and @mref{sparse} are both @code{true}.
+@code{display_determinant_bars} governs the display of determinants.
+
@c EXAMPLES NEEDED HERE
@opencatbox{Categories:}
@category{Matrices}
@closecatbox
@end deffn
+@c -----------------------------------------------------------------------------
+@anchor{display_determinant_bars}
+@defvr {Option variable} display_determinant_bars
+Default value: @code{true}
+
+When @code{display_determinant_bars} is @code{true},
+a determinant noun expression which has a literal matrix as its sole argument
+is displayed with a vertical bar on either side.
+
+Otherwise, @code{display_determinant_bars} is @code{false},
+or the determinant is not a noun expression,
+or its argument is not a literal matrix;
+in these cases, the expression is displayed as an ordinary function call.
+
+@opencatbox{Categories:}
+@category{Display flags and variables}
+@category{Matrices}
+@closecatbox
+
+@end defvr
+
@c -----------------------------------------------------------------------------
@anchor{detout}
@defvr {Option variable} detout
diff --git a/src/displa.lisp b/src/displa.lisp
index f02e385d7..5eb62a013 100644
--- a/src/displa.lisp
+++ b/src/displa.lisp
@@ -1269,6 +1269,17 @@
collect (list '(mequal) (format nil " Col ~d" k) ($col form k))))
result ""))
+(displa-def %determinant dim-determinant)
+
+(defmvar $display_determinant_bars t)
+
+(defun dim-determinant (form result)
+ (let ((a (rest form)))
+ (if (and $display_determinant_bars (= (length a) 1) ($matrixp (first a)))
+ (let ($display_matrix_brackets)
+ (dim-mabs `((mabs) ,(first a)) result))
+ (dimension-function form result))))
+
(displa-def mbox dim-mbox)
(displa-def %mbox dim-mbox)
commit ce80ffa0ea2fdbeb4930e66aad224b226a4d728e
Author: Robert Dodier <rob...@so...>
Date: Tue Oct 7 21:18:59 2025 -0700
New flag display_matrix_brackets; when true, display matrices with a bracket on either side,
otherwise without brackets. Default is display_matrix_brackets = true.
Has the advertised effect whether display2d_unicode is enabled or disabled.
diff --git a/doc/info/Matrices.texi.m4 b/doc/info/Matrices.texi.m4
index 0879b35fb..84b42a8d3 100644
--- a/doc/info/Matrices.texi.m4
+++ b/doc/info/Matrices.texi.m4
@@ -1580,6 +1580,25 @@ Example:
@closecatbox
@end defvr
+@c -----------------------------------------------------------------------------
+@anchor{display_matrix_brackets}
+@deffn {Option variable} display_matrix_brackets
+Default value: @code{true}
+
+When @code{display_matrix_brackets} is @code{true},
+matrices are displayed with brackets (square braces) to the left and right.
+
+When @code{display_matrix_brackets} is @code{false},
+matrices are not displayed with brackets;
+only the matrix elements are displayed.
+
+@opencatbox{Categories:}
+@category{Matrices}
+@category{Display flags and variables}
+@closecatbox
+
+@end deffn
+
@c -----------------------------------------------------------------------------
@anchor{matrix}
@deffn {Function} matrix (@var{row_1}, @dots{}, @var{row_n})
@@ -1624,6 +1643,8 @@ See @mrefcomma{eigenvalues} @mrefcomma{eigenvectors} @mrefcomma{determinant}@w{}
@mrefcomma{echelon} and @mrefdot{rank}
@c CHECK -- WE PROBABLY WANT EXHAUSTIVE LIST HERE
+@mref{display_matrix_brackets} governs the display of matrices.
+
Examples:
@itemize @bullet
diff --git a/src/displa.lisp b/src/displa.lisp
index 79ac08ff4..f02e385d7 100644
--- a/src/displa.lisp
+++ b/src/displa.lisp
@@ -1200,6 +1200,8 @@
(displa-def $matrix dim-$matrix)
(displa-def %matrix dim-$matrix)
+(defmvar $display_matrix_brackets t)
+
(defun dim-$matrix (form result)
(prog (dmstr rstr cstr consp cols)
(setq cols (if ($listp (cadr form)) (length (cadr form)) 0))
@@ -1235,13 +1237,13 @@
(if (> (+ height depth) (length linearray))
(setq consp t))
(return
- (cond ((and (not consp) (checkfit (+ 2 width)))
+ (cond ((and (not consp) (checkfit (if $display_matrix_brackets (+ 2 width) width)))
(matout dmstr cstr rstr result))
((and (not consp) (<= level 2)) (colout form result))
(t (dimension-function form result))))))
(defun matout (dmstr cstr rstr result)
- (push `(d-matrix left ,height ,depth) result)
+ (when $display_matrix_brackets (push `(d-matrix left ,height ,depth) result))
(push #\space result)
(do ((d dmstr (cdr d)) (c cstr (cdr c)) (w 0 0))
((null d))
@@ -1251,10 +1253,13 @@
(setq w (truncate (+ (car c) (caar d)) 2))
(rplaca d (cdar d)))
(setq result (cons (list (+ 2 (- (car c) w)) 0) (nreconc (car d) result))))
- (setq width (+ 2 width))
+ (if $display_matrix_brackets
+ (setq width (+ 2 width))
+ (when $display2d_unicode
+ (setq height (1- height) depth (1- depth))))
(update-heights height depth)
(rplaca (car result) (1- (caar result)))
- (push `(d-matrix right ,height ,depth) result)
+ (when $display_matrix_brackets (push `(d-matrix right ,height ,depth) result))
result)
(defun colout (form result)
@@ -1492,12 +1497,17 @@
;; Block mode i/o isn't needed since PRINC is used instead of WRITE-CHAR and
;; CURSORPOS.
-(defun output-linear (result w)
+(defun output-linear (result w &aux i0)
(draw-linear result bkptdp w)
(do ((i (1- (+ bkptht bkptdp)) (1- i)))
((< i 0))
- (cond ((null (aref linearray i)))
- (t (output-linear-one-line i)))))
+ (cond
+ ((and (null i0) (null (aref linearray i))))
+ (t
+ (when (null i0) (setq i0 i))
+ (if (null (aref linearray i))
+ (mterpri)
+ (output-linear-one-line i))))))
(defun output-linear-one-line (i)
(prog (line (n 0))
commit a70604d7822e25c8a3f36ca1613db2e3ab1b8774
Author: Robert Dodier <rob...@so...>
Date: Sun Oct 5 13:14:25 2025 -0700
New flag display_box_double_lines; when true, display box expressions with dobuble-line characters, otherwise single-line.
Only affects display when display2d_unicode is true.
diff --git a/doc/info/Expressions.texi b/doc/info/Expressions.texi
index 463fef986..eb4207467 100644
--- a/doc/info/Expressions.texi
+++ b/doc/info/Expressions.texi
@@ -474,6 +474,25 @@ unbound).
@closecatbox
@end deffn
+@c -----------------------------------------------------------------------------
+@anchor{display_box_double_lines}
+@defvr {Option variable} display_box_double_lines
+Default value: @code{true}
+
+When @code{display_box_double_lines} is @code{true},
+@code{box} expressions are displayed with Unicode double-line characters.
+
+When @code{display_box_double_lines} is @code{false},
+@code{box} expressions are displayed with Unicode single-line characters.
+
+@code{display_box_double_lines} only has any effect when @code{display2d_unicode} is @code{true}.
+
+@opencatbox{Categories:}
+@category{Expressions}
+@category{Display flags and variables}
+@closecatbox
+@end defvr
+
@c -----------------------------------------------------------------------------
@anchor{box}
@deffn {Function} box @
@@ -495,7 +514,7 @@ computations. @mref{rembox} removes the box again.
@mref{boxchar} is the character used to draw the box in @code{box} and in the
@mref{dpart} and @mref{lpart} functions.
-See also @mrefcomma{rembox} @mref{dpart} and @mrefdot{lpart}
+See also @mrefcomma{rembox} @mrefcomma{dpart} @mrefcomma{lpart} and @mrefdot{display_box_double_lines}
Examples:
diff --git a/src/displa.lisp b/src/displa.lisp
index f77080fc1..79ac08ff4 100644
--- a/src/displa.lisp
+++ b/src/displa.lisp
@@ -1284,7 +1284,21 @@
(dim-mlabox-unicode form result)
(dim-mlabox-ascii form result)))
+(defmvar $display_box_double_lines t)
+
(defun dim-mlabox-unicode (form result)
+ (if $display_box_double_lines
+ (dim-mlabox-unicode-default form result)
+ (let
+ ((*d-box-char-unicode-horz* (get-unicode-char :box-drawings-light-horizontal))
+ (*d-box-char-unicode-vert* (get-unicode-char :box-drawings-light-vertical))
+ (*d-box-char-unicode-upper-left* (get-unicode-char :box-drawings-light-down-and-right))
+ (*d-box-char-unicode-upper-right* (get-unicode-char :box-drawings-light-down-and-left))
+ (*d-box-char-unicode-lower-right* (get-unicode-char :box-drawings-light-up-and-left))
+ (*d-box-char-unicode-lower-left* (get-unicode-char :box-drawings-light-up-and-right)))
+ (dim-mlabox-unicode-default form result))))
+
+(defun dim-mlabox-unicode-default (form result)
(prog (dummy)
(setq dummy (dimension (cadr form) nil 'mparen 'mparen nil 0))
(cond ((not (checkfit (+ 2 width)))
@@ -1680,7 +1694,19 @@
(d-box-unicode h d w body)
(d-box-ascii h d w body)))
-(defun d-box-unicode (h d w body &aux dmstr)
+(defun d-box-unicode (h d w body)
+ (if $display_box_double_lines
+ (d-box-unicode-default h d w body)
+ (let
+ ((*d-box-char-unicode-horz* (get-unicode-char :box-drawings-light-horizontal))
+ (*d-box-char-unicode-vert* (get-unicode-char :box-drawings-light-vertical))
+ (*d-box-char-unicode-upper-left* (get-unicode-char :box-drawings-light-down-and-right))
+ (*d-box-char-unicode-upper-right* (get-unicode-char :box-drawings-light-down-and-left))
+ (*d-box-char-unicode-lower-right* (get-unicode-char :box-drawings-light-up-and-left))
+ (*d-box-char-unicode-lower-left* (get-unicode-char :box-drawings-light-up-and-right)))
+ (d-box-unicode-default h d w body))))
+
+(defun d-box-unicode-default (h d w body &aux dmstr)
(setq dmstr `((0 ,h ,*d-box-char-unicode-upper-right* (d-hbar ,w ,*d-box-char-unicode-horz*) ,*d-box-char-unicode-upper-left*)
(,(- (+ w 2)) 0)
(d-vbar ,h ,d ,*d-box-char-unicode-vert*)
-----------------------------------------------------------------------
hooks/post-receive
--
Maxima CAS
|