🔥 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

22 Oct
Difference between an Array and a Linked List

These differences will make you grasp the fundamentals of both Array and Linked List really quick.

And if you are preparing for any interviews, it would definitely help you.

Let's explore 👇
1️⃣ Storage
2️⃣ Size
3️⃣ Access of Elements
4️⃣ Insertion/Deletion of Elements
5️⃣ Search for Elements
6️⃣ Memory Allocation
7️⃣ Memory Usage
8️⃣ Memory Utilisation
9️⃣ Use case

Read 12 tweets
22 Oct
All you would like to know about

✪ Array Data Structure
✪ Array Operations
✪ Array Based Problems

* Time and Space Complexities covered

DSA Series: 🧵 👇
We will cover

1️⃣ Introduction
2️⃣ Array Size
3️⃣ Array Index
4️⃣ Array Dimension
5️⃣ Array Operations
6️⃣ Other Array-based Data Structures
7️⃣ Some Array-based Problems
1️⃣ Introduction

An array is a "collection of items" stored at contiguous memory locations.

Syntax: All items are written comma-separated inside square brackets.

Example: [1, 2, 3, 4, 5]

There are total 5 items in the array. 1 is the first item, 2 is the 2nd and 5 is the last.
Read 22 tweets
19 Oct
7️⃣5️⃣ Numeric Problems to strengthen your *COMPETITIVE CODING* skill

✪ Are you planning to be a competitive coder?
✪ But not sure how to start?

Don't worry. Here are 75 numeric problems that will certainly improve your competitive coding skill.

Problems listed 👇
1️⃣ Number

1️⃣ Find a digit at a specific place in a number
2️⃣ Find count of digits in a number
3️⃣ Find the largest digit
4️⃣ Find the 2nd largest digit
5️⃣ Find the smallest digit
6️⃣ Find the 2nd smallest digit
7️⃣ Find generic root (sum of all digits) of a number

++
8️⃣ Reverse the digits in a number
9️⃣ Rotate the digits in a number
1️⃣0️⃣ Is the number a palindrome?
1️⃣1️⃣ Find the binary, octal and hexadecimal equivalent
1️⃣2️⃣ Convert a binary, octal and hexadecimal to a decimal
1️⃣3️⃣ Find sum of 'n' numbers

++
Read 13 tweets
18 Oct
1️⃣0️⃣ List Sorting Techniques

Let's explore 10 famous sorting techniques through this introductory of Data Structures and Algorithms (DSA) series.

🧵 👇
We will discuss about

1️⃣ Bubble Sort
2️⃣ Selection Sort
3️⃣ Insertion Sort
4️⃣ Merge Sort
5️⃣ Quick Sort
6️⃣ Counting Sort
7️⃣ Radix Sort
8️⃣ Bucket Sort
9️⃣ Heap Sort
1️⃣0️⃣ Shell Sort

1️⃣ Bubble Sort

✪ Compare 2 consecutive elements. Swap if 1st one is larger than 2nd one.

✪ At the end of each iteration, largest element in the list bubbles up to the top of the list.
Read 13 tweets
17 Oct
4️⃣ CRUD Operations described wrt SQL, REST API and UI

🧵 👇
0️⃣ Introduction

CRUD stands for Create, Read, Update and Delete.

These are the 4 basic operations of persistent storage.

The term CRUD is also used for Database and UI.

Let's explore these 👇
1️⃣ C for Create

SQL: INSERT into TABLE_NAME VALUES (V1, V2, V3)

REST HTTP Method: POST

UI Form: User Sign Up, Creating a Blog Post etc.
Read 7 tweets
17 Oct
😊 Are you a beginner in programming domain?

😢 Are you getting confused of what approach to take while solving a problem?

🙃 Are you wondering why is DSA so important in Problem Solving?

Let's clear all confusions and master the skill through 1️⃣0️⃣ super simple steps 😎

🧵 👇
1️⃣ Read-Realise-Write-Run-Reshape

Yes. I say it often when someone asks me how to approach during solving a problem.

Let's see what are these.
1️⃣.1️⃣ Read & Realise

These 2 actions are so close to each other that we can hardly keep apart.

Do like this.

1. When you try to solve a problem, first "Read" it properly once.

2. Then, "Realise" what it is asking to solve.

++
Read 22 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

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

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(