Thursday, 7 May 2020

Matrix Utilities: Binary Operators for Real Matrices

Binary operations on two matrices are implemented in this blog post. The operations include the following (two types of operations for non-commutative operations, a single for commutative ones):

  • Addition : A + B
  • Subtraction : A - B
  • Subtraction : B - A
  • Multiplication : A * B
  • Multiplication : B * A
  • Hadamard product: A .* B
  • Kronecker product: A kron B
  • Kronecker product: B kron A

For the matrix entries in Input A and Input B, comma separated (the separation can also be a single whitespace) real numbers need to be entered into the Input boxes, with no newline after the last line. A comma at the end of each line can be added optionally for comma separated numbers.

Note that it is possible to transpose the matrices in the textareas for Input A and Input B.

Alternatively, you can load a CSV file into each of the Input boxes, by clicking on the Choose File button. There is a select drop down menu which allows you to specify into which of the Input boxes (A or B) should the CSV file be loaded. The drop down menu needs to be set appropriately before clicking on the "Chose File" button. The CSV files that need to be loaded into the two boxes must have a different name, even if the contents are the same (due to a limitation of how the CSV loading is implemented).

The precision of the results in decimal places can be specified in the text box headed "Precision (decimal places)".

To perform the calculation, simply press the button labelled "Perform matrix operation" further down this page. Before clicking on this button, you need to specify which binary operation to perform with another select drop down menu. The result will be displayed in the yellow textarea.

Precision (decimal places)

Input A

Input B

A + B