Skip to content

Commit 16bad66

Browse files
committed
Changed dim accroding to SVD of D transpose
1 parent eded93d commit 16bad66

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ The first line of the input file contains `M` followed by `N`. The second line c
4646

4747
#### Output Specification
4848
Your program should perform SVD and PCA on the given input and store the results in the variables given in the program. We will check the correctness by calling the functions from the program. You should compute following matrices and values:
49-
- U : M x M real matrix (to be computed by SVD)
50-
- SIGMA : M x N diagonal matrix of positive real numbers ( to be computed by SVD)
51-
- V_T : N x N real matrix (to be computed by SVD)
49+
- U : N x N real matrix (to be computed by SVD)
50+
- SIGMA : N x M diagonal matrix of positive real numbers ( to be computed by SVD)
51+
- V_T : M x M real matrix (to be computed by SVD)
5252
- K : number of columns (features) in reduced matrix D_HAT
5353
- D_HAT : reduced matrix (to be computed by PCA)
5454

lab2_io.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ check correctess of Singular Vector Decomposition
2525
--------------------------------------------------------------------------------------
2626
| D[0][0] | D[0][1] | ... | D[0][N-1] | D[1][0] | ... | D[1][N-1] | ... | D[M-1][N-1] |
2727
--------------------------------------------------------------------------------------
28-
U : 1D array of M x M real matrix (computed by SVD) in row-major
28+
U : 1D array of N x n real matrix (computed by SVD) in row-major
2929
--------------------------------------------------------------------------------------
30-
| U[0][0] | U[0][1] | ... | U[0][M-1] | U[1][0] | ... | U[1][M-1] | ... | U[M-1][M-1] |
30+
| U[0][0] | U[0][1] | ... | U[0][N-1] | U[1][0] | ... | U[1][N-1] | ... | U[N-1][N-1] |
3131
--------------------------------------------------------------------------------------
32-
SIGMA : 1D array of M x N diagonal matrix of positive real numbers (computed by SVD),
32+
SIGMA : 1D array of N x M diagonal matrix of positive real numbers (computed by SVD),
3333
consisting only digonal elements.
34-
#elements in SIGMA is M
34+
#elements in SIGMA is N
3535
-------------------------------------------------------------------
36-
| SIGMA[0][0] | SIGMA[1][1] | SIGMA[2][2] | ... | SIGMA[M-1][M-1] |
36+
| SIGMA[0][0] | SIGMA[1][1] | SIGMA[2][2] | ... | SIGMA[N-1][N-1] |
3737
-------------------------------------------------------------------
38-
V_T : 1D array of N x N real matrix (computed by SVD) in row-major
38+
V_T : 1D array of M x M real matrix (computed by SVD) in row-major
3939
--------------------------------------------------------------------------------
40-
| V_T[0][0] | V_T[0][1] | ... | V_T[0][N-1] | V_T[1][0] | ... | V_T[N-1][N-1] |
40+
| V_T[0][0] | V_T[0][1] | ... | V_T[0][M-1] | V_T[1][0] | ... | V_T[M-1][M-1] |
4141
--------------------------------------------------------------------------------
4242
K : number of coulmns (features) in reduced matrix D_HAT
4343
D_HAT : reduced matrix (computed by PCA) in row-major

lab2_omp.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ To be implemented
1212
--------------------------------------------------------------------------------------
1313
| D[0][0] | D[0][1] | ... | D[0][N-1] | D[1][0] | ... | D[1][N-1] | ... | D[M-1][N-1] |
1414
--------------------------------------------------------------------------------------
15-
U : 1D array of M x M real matrix in row-major (to be computed)
15+
U : 1D array of N x N real matrix in row-major (to be computed)
1616
--------------------------------------------------------------------------------------
17-
| U[0][0] | U[0][1] | ... | U[0][M-1] | U[1][0] | ... | U[1][M-1] | ... | U[M-1][M-1] |
17+
| U[0][0] | U[0][1] | ... | U[0][N-1] | U[1][0] | ... | U[1][N-1] | ... | U[N-1][N-1] |
1818
--------------------------------------------------------------------------------------
19-
SIGMA : 1D array of M x N diagonal matrix of positive real numbers (to be computed)
19+
SIGMA : 1D array of N x M diagonal matrix of positive real numbers (to be computed)
2020
format: consists only digonal elements
21-
#elements in SIGMA is M
21+
#elements in SIGMA is N
2222
-------------------------------------------------------------------
23-
| SIGMA[0][0] | SIGMA[1][1] | SIGMA[2][2] | ... | SIGMA[M-1][M-1] |
23+
| SIGMA[0][0] | SIGMA[1][1] | SIGMA[2][2] | ... | SIGMA[N-1][N-1] |
2424
-------------------------------------------------------------------
25-
V_T : 1D array of N x N real matrix in row-major (to be computed)
25+
V_T : 1D array of M x M real matrix in row-major (to be computed)
2626
-------------------------------------------------------------------------------
27-
| V_T[0][0] | V_T[0][1] | ... | V_T[0][N-1] | V_T[1][0] | ... | V_T[N-1][N-1] |
27+
| V_T[0][0] | V_T[0][1] | ... | V_T[0][M-1] | V_T[1][0] | ... | V_T[M-1][M-1] |
2828
-------------------------------------------------------------------------------
2929
*/
3030
void SVD(int M, int N, float* D, float** U, float** SIGMA, float** V_T);
@@ -41,15 +41,15 @@ To be implemented
4141
--------------------------------------------------------------------------------------
4242
| D[0][0] | D[0][1] | ... | D[0][N-1] | D[1][0] | ... | D[1][N-1] | ... | D[M-1][N-1] |
4343
--------------------------------------------------------------------------------------
44-
U : 1D array of M x M real matrix in row-major (input)
44+
U : 1D array of N x N real matrix in row-major (input)
4545
--------------------------------------------------------------------------------------
46-
| U[0][0] | U[0][1] | ... | U[0][M-1] | U[1][0] | ... | U[1][M-1] | ... | U[M-1][M-1] |
46+
| U[0][0] | U[0][1] | ... | U[0][N-1] | U[1][0] | ... | U[1][N-1] | ... | U[N-1][N-1] |
4747
--------------------------------------------------------------------------------------
48-
SIGMA : 1D array of M x N diagonal matrix of positive real numbers (input)
48+
SIGMA : 1D array of N x M diagonal matrix of positive real numbers (input)
4949
format: consists only digonal elements
50-
#elements in SIGMA is M
50+
#elements in SIGMA is N
5151
-------------------------------------------------------------------
52-
| SIGMA[0][0] | SIGMA[1][1] | SIGMA[2][2] | ... | SIGMA[M-1][M-1] |
52+
| SIGMA[0][0] | SIGMA[1][1] | SIGMA[2][2] | ... | SIGMA[N-1][N-1] |
5353
-------------------------------------------------------------------
5454
D_HAT : 1D array of reduced M x K real matrix in row-major (to be computed)
5555
-----------------------------------------------------------------------------------------

main_omp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ int main(int argc, char const *argv[])
2626
int M; //no of rows (samples) in input matrix D (input)
2727
int N; //no of columns (features) in input matrix D (input)
2828
float* D; //1D array of M x N matrix to be reduced (input)
29-
float* U; //1D array of M x M matrix U (to be computed by SVD)
30-
float* SIGMA; //1D array of M x N diagonal matrix SIGMA (to be computed by SVD)
31-
float* V_T; //1D array of N x N matrix V_T (to be computed by SVD)
29+
float* U; //1D array of N x N matrix U (to be computed by SVD)
30+
float* SIGMA; //1D array of N x M diagonal matrix SIGMA (to be computed by SVD)
31+
float* V_T; //1D array of M x M matrix V_T (to be computed by SVD)
3232
int K; //no of coulmns (features) in reduced matrix D_HAT (to be computed by PCA)
3333
float *D_HAT; //1D array of M x K reduced matrix (to be computed by PCA)
3434
int retention; //percentage of information to be retained by PCA (command line input)

0 commit comments

Comments
 (0)