SlideShare a Scribd company logo
1
Addressing Formulas for Sparse Matrices Using Column
Major in 1D Arrays
 Introduction
 Sparse Matrix
 Lower Triangular Matrix
 Tri-diagonal Matrix
 Row Major Representation For Lower Triangular Matrix
 Column Major Representation For Lower Triangular Matrix
 Column Major Representation For Tri-diagonal Matrix
 Advantages of Proposed Method
 References
TABLE OF CONTENTS
2
INTRODUCTION
3
 Sparse matrix generally contains elements with zero values; examples of such kind of matrices are lower & upper
triangular matrix.
 For the solution of linear equations, these matrices have been used .
 Since many of the elements in such matrices contain zeroes. Thus a need to save space arises, either in memory or
disk.
 For lower and upper triangular matrices of 1-D array, analysis has been done. After the analysis their
corresponding addressing formulas have been developed.
 Few variants are also analyzed for lower and upper triangular matrices.
 It is needed to mention that different approaches for addressing an element of sparse matrices are remain
unanalyzed in which column major are also included.
 In this paper we analyze storage by means of 1-D array for sparse matrices of the lower triangular type, plus one
matrix of the tri-diagonal type.
 To address an element in the lower triangular matrices using row major is presented first.
 After this, a new approach based on column major is defined and analyzed for lower triangular matrices and tri-
diagonal matrices.
INTRODUCTION…
4
SPARSE MATRIX
5
 Matrices with a relatively high proportion of zero entries are called sparse matrices.
 Two general types of N-square sparse matrices, which occur in various applications, are
 Lower Triangular Matrix (LTM)
 Tri-diagonal Matrix (TDM)
 A matrix which contains nonzero elements only on or below the main
diagonal is called a lower triangular matrix i.e. above the main
diagonal all elements are zero.
 Let us define a Lower Triangular Matrix (LTM) named A of order N,
N > 0. Fig. 1 shows an example of this kind of matrix, with N = 7
 There are 7 rows and 7 columns in above 7-square LTM A. Any
element in LTM A is represented by a(J, K) where
J=0, 1, 2….7 and K=0, 1, 2….7
 In LTM A, row-1 contains 1 element and row-2 contains 2 elements.
Similarly row-3, row-4….row-7 contains 3, 4….7 numbers of
elements respectively. From above Fig. 1, it may be observed that
total number of elements in any LTM of order N can be calculated by
arithmetic progression as follows:
 1+2+3+…. +N = N(N+1)/2 (1)
Hence in LTM A, there are 7*(7+1)/2 = 28 elements.
LOWER TRIANGULAR MATRIX(LTM)
Fig. 1. Lower Triangular Matrix A (LTM A)
6
1 2 3 4 5 6 7
1 4
2 3 -5
3 1 0 6
4 -7 8 -1 3
5 5 -2 0 2 -2
6 8 4 5 -1 6 -8
7 2 7 9 0 9 5 -4
 The matrix, where nonzero entries can only occur on the diagonal or
on elements immediately above or below the diagonal, is called a tri-
diagonal matrix.
 Let us define a Tri-diagonal Matrix (TDM) named B of order N, N >
0. Fig. 2 shows an example of this kind of matrix, with N = 7
 There are 7 rows and 7 columns in above 7-square TDM B. Any
element in TDM B is represented by b(J, K) where
J=0, 1, 2….7 and K=0, 1, 2….7
 Note that TDM has N=7 elements on the diagonal and N–1=6
elements above and below the diagonal. From above Fig. 2, it may be
observed that total number of elements in any TDM of order N can
be calculated as follows:
N + (N–1) + (N–1) = 3N – 2 (2)
Hence TDM B contains at most 3N–2 nonzero elements i.e.
3*7 – 2 = 19.
TRI-DIAGONAL MATRIX(TDM)
Fig. 2. Tri-diagonal Matrix B (TDM B)
7
1 2 3 4 5 6 7
1 4 7
2 3 -5 4
3 0 6 1
4 -1 3 -3
5 2 -2 0
6 6 -8 2
7 5 -4
ROW MAJOR REPRESENTATION FOR LTM
8
4 3 -5 1 0 6 -7 8 -1 3 5 -2 0 2 -2 8 4 5 -1 6 -8 2 7 9 0 9 5 -4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
Fig. 3. 1-D representation by rows of LTM A
 Elements in LTM A are represented in Fig. 3 using 1-D array named C.
 Any element in 1-D array C is represented by C[L] where L=0, 1, 2….28
 Given an element a(J, K) belonging to the triangular array LTM A. Here, the purpose is to determine the
corresponding position of same element a(J, K) in 1-D array C.
 The position of element a(J, K) in array C is determined in the following way.
C[1]=a(1,1), C[2]=a(2,1).…C[L]=a(J,K)….C[28]=a(7,7)
 According to equation (1), number of elements in any LTM of order N is N(N+1)/2.
 So it may be observed that 1-D array C contains only N(N+1)/2 number of elements i.e. 28.
ROW MAJOR REPRESENTATION FOR LTM…
9
 Since the position of a(J, K) is required in 1-D array C. So the purpose is to calculate the formula that
gives us the integer L in terms of J and K where C[L] = a(J, K).
 I.e. L gives the address of element a(J, K) in which all the elements including a(J, K) are list up in 1-D
array C.
 To calculate the address of element a(J, K) in 1-D array C, following algorithm is used.
Step-1: Calculate the number of elements coming before Jth row, i.e. number of elements up to (J-1)th row.
Step-2: Then calculate the number of elements in Jth row including a(J, K).
Step-3: Add both the values calculated in above two steps. The result is desired value L i.e. address of element
a(J, K) in 1-D array C.
 Total numbers of elements in the rows above the element a(J, K) are calculated by arithmetic progression as
follows:
1+2+3+….+(J–1) = J(J–1)/2 (3)
and there are K elements in row-J up to and including a(J, K). The address of element a(J, K) can be
calculated by adding equation (3) with number of elements in row-J up to and including a(J, K) i.e. K. So
L = J(J–1)/2 + K (4)
yields the index that accesses the value of element a(J, K) from the linear array C.
 For example: Let’s calculate the address of an element a(5, 3) of LTM A in array C using above formula.
Here J = 5 and K = 3 Then
L = 5(5–1)/2 + 3
L= 5*4/2 + 3
L = 10 + 3
L=13
 It means the address of the desired element in 1-D array C is 13. It may be observed in Fig. 3.
ROW MAJOR REPRESENTATION FOR LTM…
10
11
 The approach is to insert the same elements of LTM A in another 1-D array named D column wise.
 Elements in LTM A are represented in Fig. 4 using 1-D array D.
 Any element in 1-D array D is represented by D[L] where L=0, 1, 2….28
 Given an element a(J, K) belonging to the triangular array LTM A. Here, the purpose is to determine the
corresponding position of same element a(J, K) in 1-D array D.
 The position of element a(J, K) in array D is determined in the following way.
D[1]=a(1,1), D[2]=a(2,1), D[3]=a(3,1) .…D[L]=a(J,K)…. D[28]=a(7,7)
COLUMN MAJOR REPRESENTATION FOR LTM
4 3 1 -7 5 8 2 -5 0 8 -2 4 7 6 -1 0 5 9 3 2 -1 0 -2 6 9 -8 5 -4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
Fig. 4. 1-D representation by columns of LTM A
12
 Since the position of a(J, K) is required in 1-D array D. So the purpose is to calculate the formula that gives us the
integer L in terms of J and K where D[L] = a(J, K).
 I.e. L gives the address of element a(J, K) in which all the elements including a(J, K) are list up in 1-D array D.
 To calculate the address of element a(J, K) in 1-D array D, following algorithm is used.
Step-1: Calculate the number of elements coming after Kth column, i.e. total number of elements coming
from (K+1)th column to Nth column.
Step-2: Then calculate the number of elements in Kth column coming after the element a(J, K).
Step-3: Add both the values calculated in above two steps. The result is total number of elements coming
after element a(J, K).
Step-4: Subtract the value of Step-3 from equation (1) i.e. total number of elements in LTM A. The result is
desired value L i.e. address of element a(J, K) in 1-D array D.
COLUMN MAJOR REPRESENTATION FOR LTM…
13
 Total number of elements coming from (N–K)th i.e. (K+1)th to Nth column can be calculated by arithmetic
progression as follows:
1 + 2 + 3 + …. + (N–K) = (N–K)(N–K+1)/2 (5)
and there are (N-J) elements in same column Kth after a(J, K).
 So total number of elements after element a(J, K) are:
{(N–K)(N–K+1)/2} + (N–J) (6)
 According to Step-4, address of element a(J, K) of LTM A can be calculated by subtracting the total number of
elements coming after a(J, K) from total number of elements in LTM A. Subtract equation (6) from equation (1)
i.e.
L= {N(N + 1)/2} – {(N–K)(N–K+1)/2 + (N–J)} (7)
yields the index that accesses the value of element a(J, K) from the linear array D.
 For example: calculate the address of same element a(5, 3) of LTM A in array D, according to proposed method.
Here J = 5 , K = 3 and N = 7
Then L = {7(7+1)/2} – {(7–3)(7–3+1)/2 + (7–5)}
L = 28 – {(4*5/2) + 2}
L = 28 – 12 = 16
 It means the address of the same element in 1-D array D is 16. The same may be observed in Fig. 4.
COLUMN MAJOR REPRESENTATION FOR LTM…
14
 The approach is to insert the elements of TDM B in another 1-D array named E column wise. Elements in TDM B
are represented in Fig. 5 using 1-D array E.
 Any element in 1-D array E is represented by E[L] where L=0, 1, 2….19
 Given an element b(J, K) belonging to the TDM B. Here, the purpose is to determine the corresponding position of
same element b(J, K) in 1-D array E.
 The position of the element b(J, K) in array E is determined in the following way.
E[1]=b(1,1), E[2]=b(2,1), E[3]=b(1,2) .…E[L]=b(J,K)…. E[19]=b(7,7)
 It may be observed initially from equation (2) that array E contains only (3N – 2) number of elements i.e. 19.
COLUMN MAJOR REPRESENTATION FOR TDM
4 3 7 -5 0 4 6 -1 1 3 2 -3 -2 6 0 -8 5 2 -4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Fig. 5. 1-D representation by columns of TDM B
15
 Since the position of b(J, K) is required in 1-D array E. So the purpose is to calculate the formula that gives us the
integer L in terms of J and K where E[L] = b(J, K).
 I.e. L gives the address of element b(J, K) in which all the elements including b(J, K) are list up in 1-D array E.
 To calculate the address of element b(J, K) in 1-D array E, following algorithm is used.
Step-1: Calculate the number of elements coming before Kth column, i.e. number of elements upto (K–1)th
column.
Step-2: Then calculate the number of elements in Kth column coming before element b(J, K).
Step-3: Add both the values calculated in above two steps and also add 1 in it for b(J, K) itself. The result is
desired value L i.e. address of element b(J, K) in 1-D array E.
COLUMN MAJOR REPRESENTATION FOR TDM…
16
 Total number of elements coming before the column of element b(J, K) is
3(K–2) + 2 (8)
 Total number of elements coming before b(J, K) in Kth column is (J–K+1).
 According to Step-3, address of element b(J, K) in 1-D array E can be calculated by adding above value (J–K+1)
and equation (8). Further add 1 for b(J, K) itself. So
L= [3(K–2)+2] + [J–K+1] + 1
L= 2K + J – 2 (9)
yields the index that accesses the value of element b(J, K) from the linear array E.
 For example, Let’s calculate the address of an element b(5, 6) of TDM B in array E, according to proposed
method.
Here J = 5, K = 6 and N = 7
Then
L = 2*6 + 5 – 2
L = 12 + 5 – 2
L = 15
 It means the address of the element in 1-D array E is 15. It can be observed in Fig. 5.
COLUMN MAJOR REPRESENTATION FOR TDM…
17
 Two methods are generally used to traverse the elements of any sparse matrix.
 The first method is row wise and second method is column wise.
 During traversal few of the elements appears first in column wise rather than row wise.
 In this scenario proposed method is useful to access the elements easily.
ADVANTAGES OF PROPOSED METHOD
18
REFERENCES
[1] Grossman S., “Álgebra Lineal,” McGraw Hill, 1996.
[2] Cairó O. & Guardati S., “Data Structures,” McGraw−Hill, 2005.
[3] Horowitz E. & Sahni S., “Fundamentals of data Structures in Pascal,” Computer Science Press, 1990.
[4] Moreno F. & Flórez R., “Fórmulas de Direccionamiento en Matrices Triangulares,” Journal Facultad de Ingeniería
Universidad de Antioquia. Medellín, 2001.
[5] Seymour Lipschutz, “Data Structures,” McGraw-Hill, 2014.
THANK YOU
19

More Related Content

Similar to Addressing Formulas for Sparse Matrices Using Column Major in 1D Arrays.pptx

Matrices
MatricesMatrices
Arrays Data Structure
Arrays Data StructureArrays Data Structure
Arrays Data Structure
student
 
Ch8b
Ch8bCh8b
2-D array
2-D array2-D array
Hermite integrators and 2-parameter subgroup of Riordan group
Hermite integrators and 2-parameter subgroup of Riordan groupHermite integrators and 2-parameter subgroup of Riordan group
Hermite integrators and 2-parameter subgroup of Riordan group
Keigo Nitadori
 
Array
ArrayArray
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHIBCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
Sowmya Jyothi
 
Business mathametics and statistics b.com ii semester (2)
Business mathametics and statistics b.com ii semester (2)Business mathametics and statistics b.com ii semester (2)
Business mathametics and statistics b.com ii semester (2)
shamimakamili
 
Debojyoit
Debojyoit Debojyoit
Debojyoit
guest6e2f9e
 
Bcsl 033 solve assignment
Bcsl 033 solve assignmentBcsl 033 solve assignment
Chap05alg
Chap05algChap05alg
Chap05alg
Munhchimeg
 
Chap05alg
Chap05algChap05alg
Chap05alg
Munkhchimeg
 
Mergesort
MergesortMergesort
Mergesort
luzenith_g
 
DAA-Divide and Conquer methodology, DAA 2024
DAA-Divide and Conquer methodology, DAA 2024DAA-Divide and Conquer methodology, DAA 2024
DAA-Divide and Conquer methodology, DAA 2024
RUHULAMINHAZARIKA
 
arrays.pptx
arrays.pptxarrays.pptx
arrays.pptx
NehaJain919374
 
Unit 7 sorting
Unit 7   sortingUnit 7   sorting
Unit 7 sorting
kalyanineve
 
unit-2-dsa.pptx
unit-2-dsa.pptxunit-2-dsa.pptx
unit-2-dsa.pptx
sayalishivarkar1
 
Calculus and matrix algebra notes
Calculus and matrix algebra notesCalculus and matrix algebra notes
Calculus and matrix algebra notes
VICTOROGOT4
 
1. Introduction.pptx
1. Introduction.pptx1. Introduction.pptx
1. Introduction.pptx
SungaleliYuen
 
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
widespreadpromotion
 

Similar to Addressing Formulas for Sparse Matrices Using Column Major in 1D Arrays.pptx (20)

Matrices
MatricesMatrices
Matrices
 
Arrays Data Structure
Arrays Data StructureArrays Data Structure
Arrays Data Structure
 
Ch8b
Ch8bCh8b
Ch8b
 
2-D array
2-D array2-D array
2-D array
 
Hermite integrators and 2-parameter subgroup of Riordan group
Hermite integrators and 2-parameter subgroup of Riordan groupHermite integrators and 2-parameter subgroup of Riordan group
Hermite integrators and 2-parameter subgroup of Riordan group
 
Array
ArrayArray
Array
 
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHIBCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
BCA DATA STRUCTURES LINEAR ARRAYS MRS.SOWMYA JYOTHI
 
Business mathametics and statistics b.com ii semester (2)
Business mathametics and statistics b.com ii semester (2)Business mathametics and statistics b.com ii semester (2)
Business mathametics and statistics b.com ii semester (2)
 
Debojyoit
Debojyoit Debojyoit
Debojyoit
 
Bcsl 033 solve assignment
Bcsl 033 solve assignmentBcsl 033 solve assignment
Bcsl 033 solve assignment
 
Chap05alg
Chap05algChap05alg
Chap05alg
 
Chap05alg
Chap05algChap05alg
Chap05alg
 
Mergesort
MergesortMergesort
Mergesort
 
DAA-Divide and Conquer methodology, DAA 2024
DAA-Divide and Conquer methodology, DAA 2024DAA-Divide and Conquer methodology, DAA 2024
DAA-Divide and Conquer methodology, DAA 2024
 
arrays.pptx
arrays.pptxarrays.pptx
arrays.pptx
 
Unit 7 sorting
Unit 7   sortingUnit 7   sorting
Unit 7 sorting
 
unit-2-dsa.pptx
unit-2-dsa.pptxunit-2-dsa.pptx
unit-2-dsa.pptx
 
Calculus and matrix algebra notes
Calculus and matrix algebra notesCalculus and matrix algebra notes
Calculus and matrix algebra notes
 
1. Introduction.pptx
1. Introduction.pptx1. Introduction.pptx
1. Introduction.pptx
 
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
 

Recently uploaded

ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
IJNSA Journal
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
RadiNasr
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
anoopmanoharan2
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
Divyam548318
 
Exception Handling notes in java exception
Exception Handling notes in java exceptionException Handling notes in java exception
Exception Handling notes in java exception
Ratnakar Mikkili
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
heavyhaig
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
Low power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniquesLow power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniques
nooriasukmaningtyas
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
nooriasukmaningtyas
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
yokeleetan1
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
gerogepatton
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
JamalHussainArman
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
Dr Ramhari Poudyal
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
ClaraZara1
 

Recently uploaded (20)

ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
 
Exception Handling notes in java exception
Exception Handling notes in java exceptionException Handling notes in java exception
Exception Handling notes in java exception
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
Low power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniquesLow power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniques
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
 

Addressing Formulas for Sparse Matrices Using Column Major in 1D Arrays.pptx

  • 1. 1 Addressing Formulas for Sparse Matrices Using Column Major in 1D Arrays
  • 2.  Introduction  Sparse Matrix  Lower Triangular Matrix  Tri-diagonal Matrix  Row Major Representation For Lower Triangular Matrix  Column Major Representation For Lower Triangular Matrix  Column Major Representation For Tri-diagonal Matrix  Advantages of Proposed Method  References TABLE OF CONTENTS 2
  • 3. INTRODUCTION 3  Sparse matrix generally contains elements with zero values; examples of such kind of matrices are lower & upper triangular matrix.  For the solution of linear equations, these matrices have been used .  Since many of the elements in such matrices contain zeroes. Thus a need to save space arises, either in memory or disk.  For lower and upper triangular matrices of 1-D array, analysis has been done. After the analysis their corresponding addressing formulas have been developed.
  • 4.  Few variants are also analyzed for lower and upper triangular matrices.  It is needed to mention that different approaches for addressing an element of sparse matrices are remain unanalyzed in which column major are also included.  In this paper we analyze storage by means of 1-D array for sparse matrices of the lower triangular type, plus one matrix of the tri-diagonal type.  To address an element in the lower triangular matrices using row major is presented first.  After this, a new approach based on column major is defined and analyzed for lower triangular matrices and tri- diagonal matrices. INTRODUCTION… 4
  • 5. SPARSE MATRIX 5  Matrices with a relatively high proportion of zero entries are called sparse matrices.  Two general types of N-square sparse matrices, which occur in various applications, are  Lower Triangular Matrix (LTM)  Tri-diagonal Matrix (TDM)
  • 6.  A matrix which contains nonzero elements only on or below the main diagonal is called a lower triangular matrix i.e. above the main diagonal all elements are zero.  Let us define a Lower Triangular Matrix (LTM) named A of order N, N > 0. Fig. 1 shows an example of this kind of matrix, with N = 7  There are 7 rows and 7 columns in above 7-square LTM A. Any element in LTM A is represented by a(J, K) where J=0, 1, 2….7 and K=0, 1, 2….7  In LTM A, row-1 contains 1 element and row-2 contains 2 elements. Similarly row-3, row-4….row-7 contains 3, 4….7 numbers of elements respectively. From above Fig. 1, it may be observed that total number of elements in any LTM of order N can be calculated by arithmetic progression as follows:  1+2+3+…. +N = N(N+1)/2 (1) Hence in LTM A, there are 7*(7+1)/2 = 28 elements. LOWER TRIANGULAR MATRIX(LTM) Fig. 1. Lower Triangular Matrix A (LTM A) 6 1 2 3 4 5 6 7 1 4 2 3 -5 3 1 0 6 4 -7 8 -1 3 5 5 -2 0 2 -2 6 8 4 5 -1 6 -8 7 2 7 9 0 9 5 -4
  • 7.  The matrix, where nonzero entries can only occur on the diagonal or on elements immediately above or below the diagonal, is called a tri- diagonal matrix.  Let us define a Tri-diagonal Matrix (TDM) named B of order N, N > 0. Fig. 2 shows an example of this kind of matrix, with N = 7  There are 7 rows and 7 columns in above 7-square TDM B. Any element in TDM B is represented by b(J, K) where J=0, 1, 2….7 and K=0, 1, 2….7  Note that TDM has N=7 elements on the diagonal and N–1=6 elements above and below the diagonal. From above Fig. 2, it may be observed that total number of elements in any TDM of order N can be calculated as follows: N + (N–1) + (N–1) = 3N – 2 (2) Hence TDM B contains at most 3N–2 nonzero elements i.e. 3*7 – 2 = 19. TRI-DIAGONAL MATRIX(TDM) Fig. 2. Tri-diagonal Matrix B (TDM B) 7 1 2 3 4 5 6 7 1 4 7 2 3 -5 4 3 0 6 1 4 -1 3 -3 5 2 -2 0 6 6 -8 2 7 5 -4
  • 8. ROW MAJOR REPRESENTATION FOR LTM 8 4 3 -5 1 0 6 -7 8 -1 3 5 -2 0 2 -2 8 4 5 -1 6 -8 2 7 9 0 9 5 -4 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 Fig. 3. 1-D representation by rows of LTM A  Elements in LTM A are represented in Fig. 3 using 1-D array named C.  Any element in 1-D array C is represented by C[L] where L=0, 1, 2….28  Given an element a(J, K) belonging to the triangular array LTM A. Here, the purpose is to determine the corresponding position of same element a(J, K) in 1-D array C.  The position of element a(J, K) in array C is determined in the following way. C[1]=a(1,1), C[2]=a(2,1).…C[L]=a(J,K)….C[28]=a(7,7)  According to equation (1), number of elements in any LTM of order N is N(N+1)/2.  So it may be observed that 1-D array C contains only N(N+1)/2 number of elements i.e. 28.
  • 9. ROW MAJOR REPRESENTATION FOR LTM… 9  Since the position of a(J, K) is required in 1-D array C. So the purpose is to calculate the formula that gives us the integer L in terms of J and K where C[L] = a(J, K).  I.e. L gives the address of element a(J, K) in which all the elements including a(J, K) are list up in 1-D array C.  To calculate the address of element a(J, K) in 1-D array C, following algorithm is used. Step-1: Calculate the number of elements coming before Jth row, i.e. number of elements up to (J-1)th row. Step-2: Then calculate the number of elements in Jth row including a(J, K). Step-3: Add both the values calculated in above two steps. The result is desired value L i.e. address of element a(J, K) in 1-D array C.
  • 10.  Total numbers of elements in the rows above the element a(J, K) are calculated by arithmetic progression as follows: 1+2+3+….+(J–1) = J(J–1)/2 (3) and there are K elements in row-J up to and including a(J, K). The address of element a(J, K) can be calculated by adding equation (3) with number of elements in row-J up to and including a(J, K) i.e. K. So L = J(J–1)/2 + K (4) yields the index that accesses the value of element a(J, K) from the linear array C.  For example: Let’s calculate the address of an element a(5, 3) of LTM A in array C using above formula. Here J = 5 and K = 3 Then L = 5(5–1)/2 + 3 L= 5*4/2 + 3 L = 10 + 3 L=13  It means the address of the desired element in 1-D array C is 13. It may be observed in Fig. 3. ROW MAJOR REPRESENTATION FOR LTM… 10
  • 11. 11  The approach is to insert the same elements of LTM A in another 1-D array named D column wise.  Elements in LTM A are represented in Fig. 4 using 1-D array D.  Any element in 1-D array D is represented by D[L] where L=0, 1, 2….28  Given an element a(J, K) belonging to the triangular array LTM A. Here, the purpose is to determine the corresponding position of same element a(J, K) in 1-D array D.  The position of element a(J, K) in array D is determined in the following way. D[1]=a(1,1), D[2]=a(2,1), D[3]=a(3,1) .…D[L]=a(J,K)…. D[28]=a(7,7) COLUMN MAJOR REPRESENTATION FOR LTM 4 3 1 -7 5 8 2 -5 0 8 -2 4 7 6 -1 0 5 9 3 2 -1 0 -2 6 9 -8 5 -4 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 Fig. 4. 1-D representation by columns of LTM A
  • 12. 12  Since the position of a(J, K) is required in 1-D array D. So the purpose is to calculate the formula that gives us the integer L in terms of J and K where D[L] = a(J, K).  I.e. L gives the address of element a(J, K) in which all the elements including a(J, K) are list up in 1-D array D.  To calculate the address of element a(J, K) in 1-D array D, following algorithm is used. Step-1: Calculate the number of elements coming after Kth column, i.e. total number of elements coming from (K+1)th column to Nth column. Step-2: Then calculate the number of elements in Kth column coming after the element a(J, K). Step-3: Add both the values calculated in above two steps. The result is total number of elements coming after element a(J, K). Step-4: Subtract the value of Step-3 from equation (1) i.e. total number of elements in LTM A. The result is desired value L i.e. address of element a(J, K) in 1-D array D. COLUMN MAJOR REPRESENTATION FOR LTM…
  • 13. 13  Total number of elements coming from (N–K)th i.e. (K+1)th to Nth column can be calculated by arithmetic progression as follows: 1 + 2 + 3 + …. + (N–K) = (N–K)(N–K+1)/2 (5) and there are (N-J) elements in same column Kth after a(J, K).  So total number of elements after element a(J, K) are: {(N–K)(N–K+1)/2} + (N–J) (6)  According to Step-4, address of element a(J, K) of LTM A can be calculated by subtracting the total number of elements coming after a(J, K) from total number of elements in LTM A. Subtract equation (6) from equation (1) i.e. L= {N(N + 1)/2} – {(N–K)(N–K+1)/2 + (N–J)} (7) yields the index that accesses the value of element a(J, K) from the linear array D.  For example: calculate the address of same element a(5, 3) of LTM A in array D, according to proposed method. Here J = 5 , K = 3 and N = 7 Then L = {7(7+1)/2} – {(7–3)(7–3+1)/2 + (7–5)} L = 28 – {(4*5/2) + 2} L = 28 – 12 = 16  It means the address of the same element in 1-D array D is 16. The same may be observed in Fig. 4. COLUMN MAJOR REPRESENTATION FOR LTM…
  • 14. 14  The approach is to insert the elements of TDM B in another 1-D array named E column wise. Elements in TDM B are represented in Fig. 5 using 1-D array E.  Any element in 1-D array E is represented by E[L] where L=0, 1, 2….19  Given an element b(J, K) belonging to the TDM B. Here, the purpose is to determine the corresponding position of same element b(J, K) in 1-D array E.  The position of the element b(J, K) in array E is determined in the following way. E[1]=b(1,1), E[2]=b(2,1), E[3]=b(1,2) .…E[L]=b(J,K)…. E[19]=b(7,7)  It may be observed initially from equation (2) that array E contains only (3N – 2) number of elements i.e. 19. COLUMN MAJOR REPRESENTATION FOR TDM 4 3 7 -5 0 4 6 -1 1 3 2 -3 -2 6 0 -8 5 2 -4 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Fig. 5. 1-D representation by columns of TDM B
  • 15. 15  Since the position of b(J, K) is required in 1-D array E. So the purpose is to calculate the formula that gives us the integer L in terms of J and K where E[L] = b(J, K).  I.e. L gives the address of element b(J, K) in which all the elements including b(J, K) are list up in 1-D array E.  To calculate the address of element b(J, K) in 1-D array E, following algorithm is used. Step-1: Calculate the number of elements coming before Kth column, i.e. number of elements upto (K–1)th column. Step-2: Then calculate the number of elements in Kth column coming before element b(J, K). Step-3: Add both the values calculated in above two steps and also add 1 in it for b(J, K) itself. The result is desired value L i.e. address of element b(J, K) in 1-D array E. COLUMN MAJOR REPRESENTATION FOR TDM…
  • 16. 16  Total number of elements coming before the column of element b(J, K) is 3(K–2) + 2 (8)  Total number of elements coming before b(J, K) in Kth column is (J–K+1).  According to Step-3, address of element b(J, K) in 1-D array E can be calculated by adding above value (J–K+1) and equation (8). Further add 1 for b(J, K) itself. So L= [3(K–2)+2] + [J–K+1] + 1 L= 2K + J – 2 (9) yields the index that accesses the value of element b(J, K) from the linear array E.  For example, Let’s calculate the address of an element b(5, 6) of TDM B in array E, according to proposed method. Here J = 5, K = 6 and N = 7 Then L = 2*6 + 5 – 2 L = 12 + 5 – 2 L = 15  It means the address of the element in 1-D array E is 15. It can be observed in Fig. 5. COLUMN MAJOR REPRESENTATION FOR TDM…
  • 17. 17  Two methods are generally used to traverse the elements of any sparse matrix.  The first method is row wise and second method is column wise.  During traversal few of the elements appears first in column wise rather than row wise.  In this scenario proposed method is useful to access the elements easily. ADVANTAGES OF PROPOSED METHOD
  • 18. 18 REFERENCES [1] Grossman S., “Álgebra Lineal,” McGraw Hill, 1996. [2] Cairó O. & Guardati S., “Data Structures,” McGraw−Hill, 2005. [3] Horowitz E. & Sahni S., “Fundamentals of data Structures in Pascal,” Computer Science Press, 1990. [4] Moreno F. & Flórez R., “Fórmulas de Direccionamiento en Matrices Triangulares,” Journal Facultad de Ingeniería Universidad de Antioquia. Medellín, 2001. [5] Seymour Lipschutz, “Data Structures,” McGraw-Hill, 2014.