dCode is free and its tools are a valuable help in games, puzzles and problems to solve every day! You have a problem, an idea for a project, a specific need and dCode can not (yet) help you? You need custom development? Contact-me!

Tool to calculate the direct sums of matrices. The direct sum calculates the sum of N matrices of different sizes.

Answers to Questions

How to add 2 matrices with direct sum?

Consider \( M_1=[a_{ij}] \) a matrix of \( m \) lines and \( n \) columns and \( M_2=[b_{ij}] \) a matrix of \( p \) lines and \( q \) columns.

The direct sum of these 2 matrices is noted with the character ⊕ (circled plus sign) \( M_1 \oplus M_2 \) and is a matrix of \( m+p \) lines and \( n+q \) columns.

$$ A \oplus B = \begin{bmatrix} [a_{ij}] & [0] \\ [0] & [b_{ij}] \end{bmatrix} $$

The addition by direct sum does not require any calculation, just copy the matrices diagonally, into a larger one, and fill with zeros.

The direct sum operation must be distinguished from the conventional operation of matrix addition, although it may take different size matrices, the result is not at all identical.

How to add N matrices with direct sum?

The direct addition is generalizable to N matrices, but the order matter.

$$ A \oplus B \oplus C = ( A \oplus B ) \oplus C \neq A \oplus ( B \oplus C ) $$

Ask a new question

Source code

dCode retains ownership of the source code of the script Matrix Direct Sum online. Except explicit open source licence (indicated Creative Commons / free), any algorithm, applet, snippet, software (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, translator), or any function (convert, solve, decrypt, encrypt, decipher, cipher, decode, code, translate) written in any informatic langauge (PHP, Java, C#, Python, Javascript, Matlab, etc.) which dCode owns rights will not be given for free. So if you need to download the online Matrix Direct Sum script for offline use, check contact page !

dCode uses cookies to customize the site content, analyze user behavior and adapt dCode to your use. Some data is stored and collected for advertising purposes and may be shared with our partners. OK