Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 580885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:31:14+00:00 2026-05-13T14:31:14+00:00

I am using jama libarary for matrix. I used following matrix but when i

  • 0

I am using jama libarary for matrix. I used following matrix but when i tried to get S, it gave me error.

1.0    1.0    0.0    1.0    0.0    0.0    0.0    0.0    0.0   11.0    1.0
1.0    0.0    0.0    0.0    0.0    0.0    1.0    0.0    0.0   12.0    2.0
1.0    1.0    0.0    0.0    0.0    0.0    0.0    0.0    1.0   13.0    3.0

When I tried to get S it produce following error.

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
    at Jama.SingularValueDecomposition.getS(SingularValueDecomposition.java:507)
    at SVD2.main(SVD2.java:19)

Here is the code

public class SVD2 {
    public static void main(String[] args) {
        double[][] vals = {
              {1,1,0,1,0,0,0,0,0,11,1},
              {1,0,0,0,0,0,1,0,0,12,2},
              {1,1,0,0,0,0,0,0,1,13,3}
              };
        Matrix A = new Matrix(vals,3,11);
        System.out.println("The Matrix A is ");
        A.print(11, 2);
        System.out.println();

        System.out.println("The SVD of A is ");
        SingularValueDecomposition svd = A.svd();
        Matrix S = svd.getS();       
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:31:15+00:00Added an answer on May 13, 2026 at 2:31 pm

    For Jama’s singular value decomposition, the number of rows must not be less than the number of columns. Maybe you should try SVD on the transpose of the matrix you provided.

    EDIT: Here’s the relevant code from SingularValueDecomposition.java:

       public Matrix getS () {
          Matrix X = new Matrix(n,n);
          double[][] S = X.getArray();
          for (int i = 0; i < n; i++) {
             for (int j = 0; j < n; j++) {
                S[i][j] = 0.0;
             }
             S[i][i] = this.s[i];
          }
          return X;
       }
    

    S is constructed to be an n x n array, so the only possible source of an ArrayIndexOutOfBoundsException is from the reference to this.s[i].

    Space for s is initialized in the SingularValueDecomposition constructor (amd no where else) like this:

    s = new double [Math.min(m+1,n)];
    

    So the Jama implementation will work for a 2×3 input (contradicting what they say in the class javadoc). But I bet it won’t work for a 2×4 input.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to multiply 2 matrix using Jama library but it returns: A col:
Using the C# Facebook SDK 5.0.3 everything works fine whit the client.Get(/me). But when
i am making using of the jama package for finding the lsa . I
Using the navigator.geolocation object in JavaScript. Trying to establish accurate ranges, but wondering exactly
Using the following code, I'm able to successfully open a raw disk on my
Using Xcode4.2.1, with a basic PhoneGap template based app. (I say template, but I
Using Rails 3.2.0.rc2 and ruby 1.9.3p0 In app/views/requests/_form.html.erb I have the following code for
using file_get_contents , I open an Internet URL and get the contents of this
For a recent set of projects I have used Eclipse, using MinGW as the
Using delphi 2010, i am wondering if there someway to escape the following string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.