CalcTree Help Pages
  • What is CalcTree?
  • Getting started
    • CalcTree Pages
    • Create a CalcTree Page
    • Add a calculation
    • Collaborate with a colleague
  • Calculations
    • Parameters
      • Math formulas
        • Parameter Data Types
        • Native Functions
          • Arithmetic Functions
          • Trigonometric Functions
          • Logical & Comparison Functions
          • Matrix & Vector Functions
          • Probability & Combinatorics Functions
          • Statistical Functions
          • String Functions
          • Utility Functions
          • Other Native Functions
        • Valid Expression Syntax
      • Supported Units
      • Dropdown List Parameters
        • Linking CSV Data to Dependent Dropdowns in CalcTree
      • Parameter Settings
    • Integrations
      • Python in CalcTree
        • Adding a Python Source
        • Defining Parameters in Python
        • Referencing Other Parameters in Python
        • Working with Units in Python
        • Creating Tables and Visuals in Python
        • Consuming Files in Python
        • Using Pre-installed Python Libraries
      • Spreadsheets [Coming Soon!]
      • File Upload
        • CSV files
      • 3rd Party Software Plugins
        • Excel
        • Grasshopper
        • ETABS [v20 & v21]
        • ETABS [v22]
        • SAP 2000
        • CSI Bridge [v26]
    • Templates [Coming Soon!]
    • Optimising your calculations
  • Pages & Reports
    • CalcTree Documents
    • Static content
    • Parametric content
      • Parametric equation
      • Inputs
      • Outputs
  • Export to PDF
  • API
    • GraphQL API
      • Generating an API key
      • Queries
        • GetCalculation
        • Calculate
      • Examples
        • Bulk calculations with Python
  • Collaborate
    • Add members
    • Review and approval
    • Add stakeholders
  • Administrate
    • CalcTree Workspace
    • Versioning and Audit trail
  • CalcTree for System Administrators
Powered by GitBook
On this page
  • Construction & Access
  • Transformation & Operations
  • Vector & Matrix Math
  • Signal Transformations
  • Sorting & Selection
  • Matrix Decomposition (Advanced)
  • Notes for CalcTree
  1. Calculations
  2. Parameters
  3. Math formulas
  4. Native Functions

Matrix & Vector Functions

PreviousLogical & Comparison FunctionsNextProbability & Combinatorics Functions

Last updated 21 hours ago

CalcTree supports a wide range of using MathJS syntax. These functions are useful for vector operations, 2D geometry, and working with tabular data.

To create a matrix or vector, use square brackets:

[1, 2, 3]          // 1D vector  
[[1, 2], [3, 4]]   // 2x2 matrix

Construction & Access

Function
Description
CalcTree Example

identity(n)

Identity matrix (n × n)

identity(3) → [[1,0,0],[0,1,0],[0,0,1]]

zeros(m, n)

Matrix of zeros

zeros(2, 3) → [[0,0,0],[0,0,0]]

ones(m, n)

Matrix of ones

ones(2, 2) → [[1,1],[1,1]]

range(start, end [, step])

Create array with range

range(1, 5) → [1,2,3,4]

size(x)

Shape of array or matrix

size([[1,2],[3,4]]) → [2,2]

row(M, i)

Return row at index i

row([[1,2],[3,4]], 1) → [3, 4]

column(M, i)

Return column at index i

column([[1,2],[3,4]], 0) → [1, 3]

count(x)

Count number of elements

count([[1,2],[3,4]]) → 4

diag(x)

Create diagonal matrix or extract diagonal

diag([1,2,3]) → [[1,0,0],[0,2,0],[0,0,3]]

Transformation & Operations

Function
Description
CalcTree Example

transpose(x)

Transpose matrix or vector

transpose([[1,2],[3,4]]) → [[1,3],[2,4]]

ctranspose(x)

Complex transpose + conjugate

ctranspose([[1+2i],[3-4i]]) → [[1-2i, 3+4i]]

flatten(x)

Flatten to 1D array

flatten([[1,2],[3,4]]) → [1,2,3,4]

reshape(x, sizes)

Reshape array

reshape([1,2,3,4], [2,2]) → [[1,2],[3,4]]

squeeze(x)

Remove singleton dimensions

squeeze([[1]]) → 1

resize(x, size [, default])

Resize and pad

resize([1,2], [4], 0) → [1,2,0,0]

rotate(vec, theta)

Rotate 2D vector counter-clockwise

rotate([1, 0], pi/2) → [0, 1]

getMatrixDataType(x)

Type of values in a matrix

getMatrixDataType([[1,2],[3,4]]) → "number"

Vector & Matrix Math

Function
Description
CalcTree Example

dot(a, b)

Dot product (vectors)

dot([2,3], [4,5]) → 23

cross(a, b)

Cross product (3D vectors)

cross([1,0,0], [0,1,0]) → [0,0,1]

norm(x [, p])

Vector or matrix norm

norm([3, 4]) → 5

det(A)

Determinant

det([[1,2],[3,4]]) → -2

inv(A)

Inverse of matrix

inv([[4,7],[2,6]])

trace(A)

Trace (sum of diagonal)

trace([[1,2],[3,4]]) → 5

sqrtm(A)

Matrix square root

sqrtm([[4,0],[0,9]]) → [[2,0],[0,3]]

expm(A)

Matrix exponential

expm([[0,1],[-1,0]])

Signal Transformations

Function
Description
CalcTree Example

fft(x)

Fast Fourier Transform

fft([0,1,0,0]) → complex array

ifft(x)

Inverse FFT

ifft([...]) → original signal

Sorting & Selection

Function
Description
CalcTree Example

sort(x)

Sort 1D array

sort([3,1,2]) → [1,2,3]

partitionSelect(x, k)

k-th order statistic in a 1D array (quickselect)

partitionSelect([3,5,1,2], 1) → 2

Matrix Decomposition (Advanced)

These are available in MathJS, but may have limited or no support in CalcTree yet.

Function
Description

eigs(A)

Eigenvalues & eigenvectors

pinv(A)

Pseudo-inverse

kron(A, B)

Kronecker product

matrixFromRows(...)

Build matrix from row vectors

matrixFromColumns(...)

Build matrix from column vectors

Notes for CalcTree

  • Use standard [a, b] and [[a, b], [c, d]] notation for vectors and matrices.

  • Most elementwise operations like dotMultiply, dotDivide, map, and reshape are supported.

  • Matrix algebra (inv, det, transpose, etc.) can be used for linear system calculations.

  • You can pass arrays from tables and use them directly in these functions.

📘 Looking for more functions? CalcTree’s expression engine is powered by . For a full list of available functions, visit the . Most functions listed there are supported in CalcTree unless otherwise noted.

matrix and array functions
MathJS
MathJS Function Reference