Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how svd(singular decompostion value) works for matrix?

how svd(singular decompostion value) works for matrix?

Scheduled Pinned Locked Moved C#
csharpalgorithmsquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Isawyouoo
    wrote on last edited by
    #1

    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;

    M 1 Reply Last reply
    0
    • I Isawyouoo

      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;

      M Offline
      M Offline
      M Badger
      wrote on last edited by
      #2

      DotNetMatrix: Simple Matrix Library for .NET[^] Downloads: MaNet: A matrix library for .NET (Rational Computing 2)[^] Matrix (mathematics) - Wikipedia[^] Singular-value decomposition - Wikipedia[^] Mike

      I 1 Reply Last reply
      0
      • M M Badger

        DotNetMatrix: Simple Matrix Library for .NET[^] Downloads: MaNet: A matrix library for .NET (Rational Computing 2)[^] Matrix (mathematics) - Wikipedia[^] Singular-value decomposition - Wikipedia[^] Mike

        I Offline
        I Offline
        Isawyouoo
        wrote on last edited by
        #3

        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)

        OriginalGriffO 1 Reply Last reply
        0
        • I Isawyouoo

          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)

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          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!

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          I 1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            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!

            I Offline
            I Offline
            Isawyouoo
            wrote on last edited by
            #5

            I will check some math then !

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups