how svd(singular decompostion value) works for matrix?
-
Hi all! this algorithm written in c# : // Derived from LINPACK code. // Initialize. double[][] A = Arg; // m = Arg.RowDimension; // n = Arg.ColumnDimension; int nu = System.Math.Min(m, n); double[] s = new double[System.Math.Min(m + 1, n)]; double[][] U = new double[m][]; for (int i = 0; i < m; i++) { U[i] = new double[nu]; } double[][] V = new double[n][]; for (int i2 = 0; i2 < n; i2++) { V[i2] = new double[n]; } double[] e = new double[n]; double[] work = new double[m]; bool wantu = true; bool wantv = true; // Reduce A to bidiagonal form, storing the diagonal elements // in s and the super-diagonal elements in e. int nct = System.Math.Min(m - 1, n); int nrt = System.Math.Max(0, System.Math.Min(n - 2, m)); for (int k = 0; k < System.Math.Max(nct, nrt); k++) { if (k < nct) { // Compute the transformation for the k-th column and // place the k-th diagonal in s[k]. // Compute 2-norm of k-th column without under/overflow. s[k] = 0; for (int i = k; i < m; i++) { s[k] = System.Math.Sqrt(s[k] * s[k] + A[i][k] * A[i][k]); } if (s[k] != 0.0) { if (A[k][k] < 0.0) { s[k] = -s[k]; } for (int i = k; i < m; i++) { A[i][k] /= s[k]; } A[k][k] += 1.0; } s[k] = -s[k]; } for (int j = k + 1; j < n; j++) { if ((k < nct) & (s[k] != 0.0)) { // Apply the transformation. double t = 0; for (int i = k; i < m; i++) { t += A[i][k] * A[i][j]; } t = (-t) / A[k][k]; for (int i = k; i < m;
-
Hi all! this algorithm written in c# : // Derived from LINPACK code. // Initialize. double[][] A = Arg; // m = Arg.RowDimension; // n = Arg.ColumnDimension; int nu = System.Math.Min(m, n); double[] s = new double[System.Math.Min(m + 1, n)]; double[][] U = new double[m][]; for (int i = 0; i < m; i++) { U[i] = new double[nu]; } double[][] V = new double[n][]; for (int i2 = 0; i2 < n; i2++) { V[i2] = new double[n]; } double[] e = new double[n]; double[] work = new double[m]; bool wantu = true; bool wantv = true; // Reduce A to bidiagonal form, storing the diagonal elements // in s and the super-diagonal elements in e. int nct = System.Math.Min(m - 1, n); int nrt = System.Math.Max(0, System.Math.Min(n - 2, m)); for (int k = 0; k < System.Math.Max(nct, nrt); k++) { if (k < nct) { // Compute the transformation for the k-th column and // place the k-th diagonal in s[k]. // Compute 2-norm of k-th column without under/overflow. s[k] = 0; for (int i = k; i < m; i++) { s[k] = System.Math.Sqrt(s[k] * s[k] + A[i][k] * A[i][k]); } if (s[k] != 0.0) { if (A[k][k] < 0.0) { s[k] = -s[k]; } for (int i = k; i < m; i++) { A[i][k] /= s[k]; } A[k][k] += 1.0; } s[k] = -s[k]; } for (int j = k + 1; j < n; j++) { if ((k < nct) & (s[k] != 0.0)) { // Apply the transformation. double t = 0; for (int i = k; i < m; i++) { t += A[i][k] * A[i][j]; } t = (-t) / A[k][k]; for (int i = k; i < m;
-
thank you for you're post, I read all the algorithms, and remain all the same. I didn't get the idea of what they do, first lines of the loop they decompose it into qr, the diagonal in s and the super diagonal in e. but after ... too hairy (eigen values, eigen vectors)
-
thank you for you're post, I read all the algorithms, and remain all the same. I didn't get the idea of what they do, first lines of the loop they decompose it into qr, the diagonal in s and the super diagonal in e. but after ... too hairy (eigen values, eigen vectors)
Then to be honest, you need to learn some math before you start implementation - if you don't understand an algorithm, you have no idea how to debug it (or even how to test it!)
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!
-
Then to be honest, you need to learn some math before you start implementation - if you don't understand an algorithm, you have no idea how to debug it (or even how to test it!)
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!