Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Testing latest pari + WASM + node.js... and it works?! Wow.

28494 views
License: GPL3
ubuntu2004
Function: Mat
Section: conversions
C-Name: gtomat
Prototype: DG
Help: Mat({x=[]}): transforms any GEN x into a matrix. Empty matrix if x is
 omitted.
Description:
 ():vec        cgetg(1, t_MAT)
 (gen):vec     gtomat($1)
Doc:
 transforms the object $x$ into a matrix.
 If $x$ is already a matrix, a copy of $x$ is created.
 If $x$ is a row (resp. column) vector, this creates a 1-row (resp.
 1-column) matrix, \emph{unless} all elements are column (resp.~row) vectors
 of the same length, in which case the vectors are concatenated sideways
 and the attached big matrix is returned.
 If $x$ is a binary quadratic form, creates the attached $2\times 2$
 matrix. Otherwise, this creates a $1\times 1$ matrix containing $x$.

 \bprog
 ? Mat(x + 1)
 %1 =
 [x + 1]
 ? Vec( matid(3) )
 %2 = [[1, 0, 0]~, [0, 1, 0]~, [0, 0, 1]~]
 ? Mat(%)
 %3 =
 [1 0 0]

 [0 1 0]

 [0 0 1]
 ? Col( [1,2; 3,4] )
 %4 = [[1, 2], [3, 4]]~
 ? Mat(%)
 %5 =
 [1 2]

 [3 4]
 ? Mat(Qfb(1,2,3))
 %6 =
 [1 1]

 [1 3]
 @eprog