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

  • Home
  • SEARCH
  • 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 3498490
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:29:46+00:00 2026-05-18T12:29:46+00:00

I need to do parallel processing of sub-matrices recursively (original matrix divided into 4

  • 0

I need to do parallel processing of sub-matrices recursively (original matrix divided into 4 passed into a method). The matrix is stored as a 2D array. I can’t copy the elements each time to a new matrix as it turns out to be very expensive. Is there someway to reference the sub-matrices in java?

Perhaps, the question was not clear, I didn’t get an answer here.

  • 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-18T12:29:47+00:00Added an answer on May 18, 2026 at 12:29 pm

    I would write a wrapper around the int[][] data and call it a Matrix class. Then write a method getSubMatrix(x, y, rows, cols). This is a simple Matrix class:

    static class Matrix {
        int[][] data;
        int x, y, columns, rows;
    
        public Matrix(int[][] data) {
            this(data, 0, 0, data.length, data[0].length);
        }
    
        private Matrix(int[][] data, int x, int y, int columns, int rows) {
            this.data = data;
            this.x = x;
            this.y = y;
            this.columns = columns;
            this.rows = rows;
        }
    
        public Matrix getSubMatrix(int x, int y, int columns, int rows) {
            return new Matrix(data, this.x + x , this.y + y, columns, rows);
        }
    
        public String toString() {
    
            StringBuffer sb = new StringBuffer();
    
            for (int i = y; i < x + rows; i++) {
                for (int j = x; j < x + columns; j++)
                    sb.append(data[i][j]).append(" ");
    
                sb.append("\n");
            }
            sb.setLength(sb.length() - 1);
    
            return sb.toString();
        }
    }
    

    This test program…:

    public static void main(String[] args) throws IOException {
    
        int[][] testData = new int[10][10];
    
        for (int i = 0; i < testData.length; i++) 
            for (int j = 0; j < testData[i].length; j++)
                testData[i][j] = 100 + i + j;
    
        Matrix full = new Matrix(testData);
    
        System.out.println("Full test matrix:");
        System.out.println(full);
    
        System.out.println();
    
        System.out.println("Part of the matrix:");
        System.out.println(full.getSubMatrix(3, 3, 3, 3));
    
    }
    

    …prints:

    Full test matrix:
    100 101 102 103 104 105 106 107 108 109 
    101 102 103 104 105 106 107 108 109 110 
    102 103 104 105 106 107 108 109 110 111 
    103 104 105 106 107 108 109 110 111 112 
    104 105 106 107 108 109 110 111 112 113 
    105 106 107 108 109 110 111 112 113 114 
    106 107 108 109 110 111 112 113 114 115 
    107 108 109 110 111 112 113 114 115 116 
    108 109 110 111 112 113 114 115 116 117 
    109 110 111 112 113 114 115 116 117 118 
    
    Part of the matrix:
    106 107 108 
    107 108 109 
    108 109 110 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the problem... For school project I need to write parallel application using
I need to run a MonteCarlo simulations in parallel on different machines. The code
I need to write a simple program that records all the input from parallel
I am currently working on a project where I need to implement a parallel
I'm experimenting with filtering through elements in parallel. For each element, I need to
Working with several DBs in parallel and need to initialize some records with hashed
I need to run in parallel multiple threads to perform some tests. My 'test
Whats a simple code that does parallel processing in python 2.7? All the examples
I have a Hibernate transactional method doImportImpl which runs multi-threaded. Certain records however need
I'm doing some parallel operations in lua. one thread for receiving, one for processing

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.