ReferencematrixInput

<matrixInput/>

An interactive matrix input where each cell accepts a math value

<matrixInput/> is an Input component that renders an empty matrix with blanks for user-input of entries.

Attributes and Properties

Attributes for <matrixInput>

Number display (5)
avoidScientificNotation

boolean. Default value: false. Whether to render numbers in full decimal form rather than scientific notation.

displayDecimals

integer. Default value: 2. Number of decimal places to display when rendering this number.

displayDigits

integer. Default value: 10. Number of significant digits to display when rendering this number.

displaySmallAsZero

number. Default value: 0. Threshold below which numbers are displayed as zero.

padZeros

boolean. Default value: false. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.

Labels (1)
labelIsName

boolean. Default value: false. Whether to use this component's name as its rendered label.

Other (14)

math. Two-way binding target for the input's value.

math. Default value: \(_\). Default value used for empty matrix cells.

forAnswer

reference. References to <answer> elements that this input should submit to.

keyword. Input format for each cell.

ValueDescription
text (default)Plain-text math notation (e.g., x^2 + 1).
latexLaTeX-formatted math (e.g., x^{2} + 1).

textList. Default value: ["f","g"]. Symbols treated as function names when parsing.

labelPosition

keyword. Position of the label relative to the input.

ValueDescription
left (default)Place the label to the left of the input.
rightPlace the label to the right of the input.

integer. Default value: 0. Minimum rendered width for each cell, in pixels.

integer. Default value: 1. Number of columns in the matrix input.

integer. Default value: 1. Number of rows in the matrix input.

parseScientificNotation

boolean. Default value: false. Whether to parse expressions like 1e3 as scientific notation.

math. Default value: \(_\). Initial matrix value displayed in the input.

boolean. Default value: true. Whether to render controls for resizing the matrix.

boolean. Default value: true. Whether multi-character symbols are split into a product of variables.

unionFromU

boolean. Default value: false. Whether "U" between sets is parsed as union.

Common to all components (9)
copy

reference. Create an independent copy of another component by reference. Enter a references a $name.

disabled

boolean. Default value: false. Whether this component is disabled and cannot be interacted with.

extend

reference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.

fixed

boolean. Default value: false. Whether this component's value is fixed and cannot be modified.

fixLocation

boolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

hide

boolean. Default value: false. Whether to hide this component from the rendered output.

isResponse

boolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.

name

text. The name used to reference this component from elsewhere in the document.

styleNumber

integer. Default value: 1. The style number used to select this component's visual styling from the available style definitions.

Properties for <matrixInput name="m">

Number display (5)
$m.avoidScientificNotation

boolean. Whether to render numbers in full decimal form rather than scientific notation.

$m.displayDecimals

integer. Number of decimal places to display when rendering this number.

$m.displayDigits

integer. Number of significant digits to display when rendering this number.

$m.displaySmallAsZero

number. Threshold below which numbers are displayed as zero.

$m.padZeros

boolean. Whether to pad displayed numbers with trailing zeros to fill the requested digits/decimals.

Labels (2)
$m.label

label. The label rendered with this component.

$m.labelIsName

boolean. Whether to use this component's name as its rendered label.

Other (24)
$m.columns

[ math ]. The matrix's entries grouped by column.

$m.disabled

boolean. Whether this component is disabled and cannot be interacted with.

$m.fixed

boolean. Whether this component's value is fixed and cannot be modified.

$m.fixLocation

boolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

$m.focused

boolean. Whether the matrix input currently has keyboard focus.

$m.format

text. Input format for each cell.

$m.functionSymbols

textList. Symbols treated as function names when parsing.

$m.hidden

boolean. Whether this component is hidden from the rendered output.

math. The current matrix being entered (live, before saving).

boolean. Whether the live matrix differs from its initial state.

$m.labelPosition

text. Position of the label relative to the input.

$m.matrix

[ math ]. The matrix as a math expression.

$m.numColumns

integer. The number of columns of the matrix.

$m.numRows

integer. The number of rows of the matrix.

$m.parseScientificNotation

boolean. Whether to parse expressions like 1e3 as scientific notation.

$m.prefill

math. Initial matrix value displayed in the input.

$m.rows

[ math ]. The matrix's entries grouped by row.

$m.shortDescription

text. A short accessibility description of this input; it is visible to screen readers but not rendered visually.

$m.showSizeControls

boolean. Whether to render controls for resizing the matrix.

$m.splitSymbols

boolean. Whether multi-character symbols are split into a product of variables.

$m.text

text. The current matrix as a text string.

$m.unionFromU

boolean. Whether "U" between sets is parsed as union.

math. The most recently saved matrix value.

boolean. Whether the saved matrix has been changed from its initial state.

Common to all components (4)
$m.doenetML

text. The DoenetML source code that produced this component.

$m.hide

boolean. Whether to hide this component from the rendered output.

$m.isResponse

boolean. Whether this component is treated as a response for the purposes of assessment.

$m.styleNumber

integer. The style number used to select this component's visual styling from the available style definitions.

Examples

Example: Default <matrixInput/>

The default <matrixInput/> contains a single input blank. Additional rows and columns are added with rendered size control buttons.


Example: A blank 2x3 <matrixInput/>

To show a <matrixInput/> of a specific, unchangeable size, use the numRows and the numColumns attributes. Set the showSizeControls attribute to false to prevent the user from altering the size.


Example: Retrieving an entry from a <matrixInput/>

Individual entries of the matrix can be accessed using array notation with the matrix property.


Example: Operations with <matrixInput/> - defined matrices

Basic matrix operations can be performed with named <matrixInput/> components. See the <matrix> component for additional examples.


Example: Prefill a <matrixInput/> with a <matrix>

To easily prefill a <matrixInput/> with specific entries, first define a <matrix> and reference it by name within the prefill attribute of the <matrixInput/>.

Attribute Examples

Attribute Example: numRows / numColumns

A <matrixInput/> of a specific size can be initialized with the numRows and the numColumns attributes.


Attribute Example: showSizeControls

The default size control buttons can be hidden by setting the showSizeControls attribute to false.


Attribute Example: prefill

To easily prefill a <matrixInput/> with specific entries, first define a <matrix> and reference it by name within the prefill attribute of the <matrixInput/>.


Attribute Example: defaultEntry

Use the defaultEntry attribute to change the prefilled value for a matrix of a specified size; the default value is an empty input box.


Attribute Example: format

The format attribute gives the option for prefilled <matrixInput/> components to contain content formatted in LaTeX. If supported, expressions entered in the prefill of the <matrixInput/> will be parsed by Doenet as math components and may be used in further computations.


Attribute Example: functionSymbols

The functionSymbols attribute is used to specify when a character is formatted as a function that takes an argument in parentheses. Default = “f”, “g”; type = textList

Try deleting the specification functionSymbols="f g h" from the example above to observe the difference in the simplification of A2A^2.


Attribute Example: splitSymbols

The splitSymbols attribute is used to modify the default mathematical simplification of multicharacter values in a <mathInput/> (think of each entry in a <matrixInput/> as a <mathInput/>). By default, Doenet assumes adjacent characters are single variables multiplied together, and “splits” them during parsing. So, for example, multicharacter values such as xyz are interpreted as the product xyzx \cdot y \cdot z. However, if you wish to treat a grouping of symbols as a single variable, you can turn off this behavior by specifying splitSymbols="false".


Attribute Example: bindValueTo

The bindValueTo attribute is used to create a bidirectional link between the value of a <matrixInput/> and that of another component. This attribute accepts a reference to a named math component or the property of a named component as input.


Attribute Example: minComponentWidth

The minComponentWidth attribute adjusts the width of the individual <mathInput/> components within the <matrixInput/>.

Property Examples

Property Example: Attributes as properties

The attributes shown above are also accessible as properties.


Property Example: valueChanged / immediateValueChanged

The valueChanged property returns the boolean value of whether the <matrixInput/> has been changed by the user when the page is updated (which occurs when the user clicks elsewhere, hits Enter, or interacts with another part of the page).

The immediateValueChanged property returns the boolean value of whether the <matrixInput/> has been changed by the user immediately as they are typing into the input.


Property Example: value / immediateValue

The value property returns the value stored in the <matrixInput/> since the most current page update (which occurs when the user clicks elsewhere, hits Enter, or interacts with another part of the page).

The immediateValue property returns the value stored in the <matrixInput/>, updated immediately as the user is typing it in.