Swapna Kumar Panda Profile picture
Oct 21, 2021 โ€ข 19 tweets โ€ข 6 min read โ€ข Read on X
๐Ÿ”ฅ MATRIX Operations implemented in JavaScript ๐Ÿš€

Welcoming you to this super exciting ๐Ÿงต where we will implement various matrix operations in JavaScript along with their Complexity Analysis (both Time and Space).

Are you excited to know? ๐Ÿ‘‡
We will cover ๐Ÿ‘‡

๐Ÿ”น Dimension
๐Ÿ”น Square Matrix
๐Ÿ”น Diagonal Matrix
๐Ÿ”น Upper Triangular
๐Ÿ”น Lower Triangular
๐Ÿ”น Identity Matrix
๐Ÿ”น Zero Matrix
๐Ÿ”น Transpose Matrix
๐Ÿ”น Scalar Multiplication
๐Ÿ”น Matrix Addition
๐Ÿ”น Matrix Subtraction
๐Ÿ”น Matrix Multiplication
๐Ÿ”น Orthogonal Matrix

โ†“
0๏ธโƒฃ Introduction

Matrix is a 2-dimensional (array) arrangement of numbers and it has vast use in Linear Algebra.

Example:
[[aโ‚โ‚, aโ‚โ‚‚, aโ‚โ‚ƒ],
[aโ‚‚โ‚, aโ‚‚โ‚‚, aโ‚‚โ‚ƒ],
[aโ‚ƒโ‚, aโ‚ƒโ‚‚, aโ‚ƒโ‚ƒ]]

Each element in the inner array is called an element of the matrix. Eg, aโ‚โ‚

++
Each element in the main array is called a row. Eg, [aโ‚โ‚, aโ‚โ‚‚, aโ‚โ‚ƒ]

A column is formed by taking elements at a specific index from each row in order. Eg, [aโ‚โ‚, aโ‚‚โ‚, aโ‚ƒโ‚]

โ†“
1๏ธโƒฃ Dimension of a Matrix

Dimension of a Matrix is specified as the number of rows and number of columns in the matrix.

Example:
[[aโ‚โ‚, aโ‚โ‚‚],
[aโ‚‚โ‚, aโ‚‚โ‚‚],
[aโ‚ƒโ‚, aโ‚ƒโ‚‚]]

Dimension is 3x2

โ†“
2๏ธโƒฃ Square Matrix

A matrix is called as a "Square Matrix" only if its "number of rows" is equal to its "number of columns".

Example:
[[aโ‚โ‚, aโ‚โ‚‚, aโ‚โ‚ƒ],
[aโ‚‚โ‚, aโ‚‚โ‚‚, aโ‚‚โ‚ƒ],
[aโ‚ƒโ‚, aโ‚ƒโ‚‚, aโ‚ƒโ‚ƒ]]

Here, number of rows is 3 and number of columns is also 3.

โ†“
3๏ธโƒฃ Diagonal Matrix

A "Diagonal Matrix" is a square matrix which has only Zeroes (0s) as its non-diagonal elements (row index = column index).

Diagonal elements can be both Non-Zero and Zero.

Example:
[[5, 0, 0],
[0, 2, 0],
[0, 0, -3]]

โ†“
4๏ธโƒฃ Upper Triangular Matrix

An "Upper Triangular Matrix" is a square matrix which has only Zeroes (0s) as elements "below" the diagonal elements.

Example:
[[5, 6, 7],
[0, 2, 3],
[0, 0, -3]]

โ†“
5๏ธโƒฃ Lower Triangular Matrix

An "Lower Triangular Matrix" is a square matrix which has only Zeroes (0s) as elements "above" the diagonal elements.

Example:
[[5, 0, 0],
[1, 2, 0],
[4, 7, -3]]

โ†“
6๏ธโƒฃ Identity/Unity Matrix

An "Identity Matrix" is a diagonal matrix with only 1s as its diagonal elements.

Example:
[[1, 0, 0],
[0, 1, 0],
[0, 0, 1]]

โ†“
7๏ธโƒฃ Zero Matrix

A "Zero Matrix" has only Zeroes (0s) as all its elements.

Example:
[[0, 0, 0],
[0, 0, 0],
[0, 0, 0]]

โ†“
8๏ธโƒฃ Transpose Matrix

A "Transpose Matrix" is formed by converting rows of a matrix into columns (and thus columns into rows).

Dimension of a transpose matrix is exactly opposite of the dimension of the original matrix.

โ†“
9๏ธโƒฃ Scalar Multiplication

By doing "Scalar Multiplication", each element of the matrix is multiplied by a scalar value.

โ†“
1๏ธโƒฃ0๏ธโƒฃ Matrix Addition

By "Matrix Addition", elements at a specific row and column from 2 matrices are added.

โ†“
1๏ธโƒฃ1๏ธโƒฃ Matrix Subtraction

By "Matrix Subtraction", elements at a specific row and column from one matrix is subtracted from the another.

โ†“
1๏ธโƒฃ2๏ธโƒฃ Matrix Multiplication

By "Matrix Multiplication", elements of a row from the first matrix is first multiplied with elements of a column from the second matrix and then summation is taken.

โ†“
1๏ธโƒฃ3๏ธโƒฃ Orthogonal Matrix

A matrix is known as "Orthogonal" when multiplied with its transpose results into an Identity Matrix.

In other words, if transpose of a matrix is equivalent to its inverse, the matrix is orthogonal.

โ†“
OMISSIONS:

Inverse and, Determinant of a Matrix are omitted because of time constraints.

But, by now you must be familiar with matrix operations. Can you implement these 2 on your own? If you do, share that here in the reply.
We reached to the end of this ๐Ÿงต. I hope you enjoyed implementing all these matrix operations in JavaScript.

If you haven't followed yet, do follow me for receiving such informative threads in future.

Share your feedbacks. Support me by giving a Like and RT.

See you soon,๐Ÿ‘‹

โ€ข โ€ข โ€ข

Missing some Tweet in this thread? You can try to force a refresh
ใ€€

Keep Current with Swapna Kumar Panda

Swapna Kumar Panda Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @swapnakpanda

Mar 15
If I need to pick ONLY FIVE courses to learn AI & ML from scratch, I'll pick:

โฏ CS221 - Artificial Intelligence
โฏ CS229 - Machine Learning
โฏ CS230 - DL
โฏ CS234 - RL
โฏ CS336 - LLM

These courses normally cost >$100K. But Stanford is offering them FREE on YouTube: Image
1. CS221 - Artificial Intelligence

๐Ÿ–‡ youtube.com/playlist?list=โ€ฆImage
2. CS229 - Machine Learning

- By Andrew Ng

๐Ÿ–‡ youtube.com/playlist?list=โ€ฆImage
Read 6 tweets
Mar 14
System Design becomes EASY after you go through these 9 excellent GitHub Repositories:
1. System Design Primer (339K โญ)

github.com/donnemartin/syโ€ฆImage
2. System Design 101 (80K โญ)

github.com/ByteByteGoHq/sโ€ฆImage
Read 10 tweets
Mar 12
If you are a software engineer who wants to upskill in system design, bookmark these 13 sites:
2. System Design Primer

github.com/donnemartin/syโ€ฆImage
Read 14 tweets
Mar 10
I wish these Mathematics Courses were available during my School Days.

10 completely free courses for Beginners:
Read 11 tweets
Feb 27
Stanford's FREE Courses on AI & ML:

โฏ CS221 - Artificial Intelligence
โฏ CS229 - Machine Learning
โฏ CS230 - Deep Learning
โฏ CS234 - Reinforcement Learning
โฏ CS224N - NLP with Deep Learning
โฏ CS336 - LLM from Scratch

All 11 course links inside:Image
1. CS221 - Artificial Intelligence

๐Ÿ–‡ youtube.com/playlist?list=โ€ฆImage
2. CS229 - Machine Learning

- By Andrew Ng

๐Ÿ–‡ youtube.com/playlist?list=โ€ฆImage
Read 11 tweets
Feb 19
JavaScript is MUST in 2026.

This is how you can MASTER it in 6 months:
โžŠ Fundamentals

Effort: 1 to 2 hours per day
Time: 2 weeks

โž€ JavaScript Engine
โž JavaScript Runtime
โž‚ Execution Context
โžƒ Hoisting
โž„ Call Stack
โž… Event Loop
โž† Callback Queue
โž‹ Variables and, Datatypes

Effort: 1 to 2 hours per day
Time: 2 weeks

โž€ Datatypes
โฏ Primitives
โฏ Literals
โฏ Numeric
โฏ Boolean
โฏ String

โž Variable
โฏ Naming
โฏ Declaration (var, let, const)
โฏ Assignment

โœง Special Topic
โฏ Type Coercion
โฏ undefined, null, NaNImage
Read 17 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(