On 1/18/2018 9:13 PM, Otared Kavian wrote:
Hi Aditya,

Thanks for sharing this nice module, it is really useful, especially when 
making documents for students while using Matlab or Scilab.

Nice indeed.

There is also in the distribution the module m-matrix.mkiv written by Hans and 
Jeong Dalyoung, which allows to manipulate matrices.
Maybe one should add the functionality of your module to the one in the 
distribution and somehow unify their environments.

I'll add this to the core:

\unprotect

%D The following code is derived from Aditya's simplematrix prototype but
%D adapted to regular mathmatrices (which saves some code so it can go into
%D the core):

\newtoks\t_math_matrix

\def\math_matrix_simple_row#1%
  {\rawprocesscommalist[#1]\math_matrix_simple_col
   \toksapp\t_math_matrix{\NR}}

\def\math_matrix_simple_col#1%
  {\toksapp\t_math_matrix{\NC#1}}

\unexpanded\def\math_matrix_simple[#1][#2]#3%
  {\begingroup
   \edef\currentmathmatrix{#1}%
   \ifsecondargument
     \setupcurrentmathmatrix[#2]%
   \fi
   \t_math_matrix\emptytoks
   \processlist[];\math_matrix_simple_row[#3]%
   \math_matrix_start\currentmathmatrix
   \the\t_math_matrix
   \math_matrix_stop
   \endgroup}

%D We hook it into the normal mathmatrix code:

\ifdefined\c!simplecommand\else\def\c!simplecommand{simplecommand}\fi

\appendtoks
    \edef\p_simplecommand{\mathmatrixparameter\c!simplecommand}%
    \ifx\p_simplecommand\empty\else

\setuevalue{\p_simplecommand}{\dodoubleempty\math_matrix_simple[\currentmathmatrix]}%
    \fi
\to \everydefinemathmatrix

%D And predefine some matrices:

\definemathmatrix[matrix:parentheses][\c!left={\left(\mskip\thinmuskip},\c!right={\mskip\thinmuskip\right)},\c!align=\v!middle]
\definemathmatrix[matrix:brackets] [\c!left={\left[\mskip\thinmuskip},\c!right={\mskip\thinmuskip\right]},\c!align=\v!middle] \definemathmatrix[matrix:bars] [\c!left={\left|\mskip\thinmuskip},\c!right={\mskip\thinmuskip\right|},\c!align=\v!middle]

\definemathmatrix[thematrix][matrix:parentheses][\c!simplecommand=thematrix]

\protect

\starttext

$\thematrix{1,2,3,4;5,6,7,8;9,10,11,12}$

$\startthematrix
    \NC 1\NC 2\NC 3\NC 4\NR
    \NC 5\NC 6\NC 7\NC 8\NR
    \NC 9\NC10\NC11\NC12\NR
\stopthematrix$

\stoptext



Best regards: OK

On 18 Jan 2018, at 04:53, Aditya Mahajan <adit...@umich.edu> wrote:
[…]

If you type a lot of such matrices, you might find the attached module 
interesting. Using it you can use matlab-like syntax for writing matrices:

\usemodule[simplematrix]
\definesimplematrix[MATRIX][fence=parenthesis, align=middle]

\starttext
$\MATRIX{1,2,3,4;5,6,7,8;9,10,11,12}$
\stoptext

Aditya<t-simplematrix.mkvi>___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________



--

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to