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 6037277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:02:58+00:00 2026-05-23T06:02:58+00:00

I have one 2D matrix. My problem requires me to logically divide it into

  • 0

I have one 2D matrix. My problem requires me to logically divide it into 4 sub-matrices. e.g if my original matrix is 4*4 then there are 4 sub-matrices of 2*2.
one starts at (0,0) other are (0,2), (2,0) and (2,2) index of original matrix.
I am accessing and setting values many times during program. I want to access the sub-matrix element by something like matrix[x][y].at(row,col) where x,y specify sub-matrix number and row,col denote element withing that sub-matrix at(row,col).
e.g
matrix[2][2].at[0][0] –> should give first element in 4th sub-matrix.

Any help is deeply appreciated.

Thanks in Advance

  • 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-23T06:02:59+00:00Added an answer on May 23, 2026 at 6:02 am

    I’m not sure what the issue is here. Basically you just want a pseudo semantic api for addressing elements of a 2-d matrix. You note (presumed random) reads and writes to array. We’ll assume you are not dealing with threading issues.

    A 2-dim array of type Foo, Foo[][], certainly can work. You just basically need to wrap it.

    public class Matrix<T> {
        public interface Quadrant<T> {
            T get(int i, int j);
            void set(T v, int i, int j);
        }
        public static final int XDIM = 4;
        public static final int YDIM = 4;
        private final Object[][] matrix = new Object[XDIM][YDIM];
        public Matrix() { /* .. */ }
        public Quadrant<T> quadrant(final int x, final int y) {
            return new Quadrant<T> () {
                @SuppressWarnings("unchecked")
                @Override public final T get(int i, int j) {
                    return (T) matrix [x+i][y+j]; // todo: range checks, etc.
                }
                @Override public final void set(T v, int i, int j) {
                    matrix [x+i][y+j] = v; // todo: range checks, etc.
                }
            };
        }
        public static void main(String[] args) {
            Matrix<Object> m = new Matrix<Object>();
            m.quadrant(2, 2).set("hi there!", 0, 1);
            System.out.format("{%d, %d}:(%d, %d) => %s\n", 2, 2, 0, 1, m.quadrant(2, 2).get(0, 1));
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one thread that writes results into a Queue. In another thread (GUI),
I have an optimizer that solves a transportation problem, using a cost matrix of
I have a problem when rendering cubes in OpenGL.I am drawing two cubes, one
I have a classic physics-thread vs. graphics-thread problem: Say I'm running one thread for
I have two matrices I want to perform a loop on. My problem is
I have an algorithmic problem in which I have derived a transfer matrix between
As in my previous question I have the following problem. I have a matrix
I have a problem making a bigger matrix out of smaller matrixs. Lets suppose
I need some help in this problem I have this matrix in MATLAB: A
I have one field that I need to sum lets say named items However

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.