I have a matrix below..
I am looking for a way of Identifying every coordinate (X,Y) in the matrix Matrix(4,32)
That should be (128) unique Identifications..
For every Uniquie ID , I need to assigned or reference the ID with a uniqe double Vector [12.2, 1.2,9.4,1.4] or [1,4] matrix

Thanks in advance..

A simple get and set method for the inner vector [1,4 matirx] is a bonus.. :-)

Thanks in Advance..

final public class Matrix { private final int M; // number of rows private final int N; // number of columns private final double[][] data; // M-by-N array // create M-by-N matrix of 0's public Matrix(int M, int N) { this.M = M; this.N = N; data = new double[M][N]; } // create matrix based on 2d array public Matrix(double[][] data) { M = data.length; N = data[0].length; this.data = new double[M][N]; for (int i = 0; i < M; i++) for (int j = 0; j < N; j++) this.data[i][j] = data[i][j]; }}********************************************Accessible through Matrix myDouble = new Matrix(4,32); myDouble.show();******************************I have tried this but it comsumes lots of resourcespublic Lattice(int w, int h) { width = w; height = h; matrix = new Node[width][height]; float xstep = .5f / (float)width; float ystep = .5f / (float)height; for (int x=0; x<w; x++) { for (int y=0; y<h; y++) { matrix[x][y] = new Node(4); matrix[x][y].setX(x); matrix[x][y].setY(y); // System.out.println(matrix.clone()); matrix[x][y].setWeight(0, (xstep * x) + (ystep * y)); matrix[x][y].setWeight(1, (xstep * x) + (ystep * y)); matrix[x][y].setWeight(2, (xstep * x) + (ystep * y)); matrix[x][y].setWeight(3, (xstep * x) + (ystep * y)); // System.out.println(matrix.length); } } }

What I need is this
final double[][] data = new double[M][N]
x and y coordinate of the position of [M][N] This will give 16 (different unique coordinates)

OK, you can have a matrix of vectors but all vectors
have ne element but for these two
which have four elemets

Wjat do you want to do wit this matrix?

0

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

I already have a matrix that generates the needed random values

If I have the coordination of the matrix.. i can just assing or refernce or associate a matrix [1, 4 ] to it

This is my problem

// create and return a random M-by-N matrix with values between 0 and 1 public static Matrix random(int M, int N) { Matrix A = new Matrix(M, N); for (int i = 0; i < M; i++) for (int j = 0; j < N; j++) A.data[i][j] = Math.random(); return A; }

This will be matrix with vectors in ecah element
but all vectors will have one element representing random double number between 0 and 1
Do you want these vectors to be of random length?

final ArrayList [][] data;
data = new ArrayList[M][N];

for(int i=0; i<M;, i++){
for (int j=0; j<N; j++){
data{M][N] = new ArrayList();

Hence .. I can call coordinate.. (x,Y) = (3,3) value = [0.5, 1.3 ,2.0 ,0.3]
I need to get this coordinate = or update it.. based on the position..
coordinate (0,0) = [0,1,2,3]

I am getting them from a file.. ..
I need to populate 2D Lattice. with values

Exampe Chess board game....

For every move a kings made.. there is a position.. or coordinate..
Hence the opponet will get the position..
Example for a starting position of a king.. I need to insert a [1,4] matirx inside this Position

Then what you probably need is for each cell of your matrix you want to
have a vector of all matrix positions, which are accessible from this point - correct?

Then by the way for each chess figue you would cretae its own matrix,
as the kinfg will have one matrix, the queen will have another, the pawn will have third matrix,

If so, you should create a class called say
a ChessField
and this class will have coordinates - two intgere numbers bewenn 0,1,...7
and methods
And metods should correspond to chess figure moves and each method will
have a return value of destnation field or even array of destination fields

so if I have a

ChessField cf = new ChessField(int m, int n);

ArrayList getKingFileds(ChessField cf){
//and here you produce array of those fileds
//which are accessible to king
//that is simle, say
ArrayList al = new ArrayList();
int x = cf.getX();
int x = cf.getY();
if(x>1){cf1 = new ChessField(x-1,y);
al.add(cf1);}
if(x<7)(...)
and so on...

}

Are you thinmkking about something like that?

and then you'll go through all positions and will generate vectos of positions
accessible for particular figure
Sounds like a good begiining for the chess program

Great!
Actually, I also liked it - never thought before
about how they porogram chess; even though, I understand, that
you are not into chess.
Anyway, let us know if you have further questions

Do you have any Idea how I can output/unit test your code to see how the system is displaying the data

I have matrix code that does just that for my class..

// print matrix to standard output public void show() { for (int i = 0; i < M; i++) { for (int j = 0; j < N; j++) System.out.printf("%9.4f ", data[i][j]); System.out.println(); } }

import java.io.*;import java.util.*;public class V { static int M = 4; static int N = 4; final static double[][][] data = new double[M][N][1]; public static void main(String[] args) { for (int i = 0; i < M; i++) { for (int j = 0; j < N; j++) { data[i][j] = getRandomVector(); } } show(); } public static void show() { for (int i = 0; i < M; i++) for (int j = 0; j < N; j++) System.out.println(Arrays.toString(data[i][j])); } public static double[] getRandomVector() { double[] vector = new double[4]; for (int i = 0; i < vector.length; i++) { vector[i] = Math.random() * 10; } return vector; }}

int M = 3; int N = 2; double[][] map = new double[M][N];System.out.println("Node " + i + ": (" + map[i] + " " + map[i] + ")");your help will be appreciated

Should admit that I again lost your thought since we were talking about chess.
Perhaps this is waht you want:

public class MatrixLattice { public MatrixLattice(){ int M = 3; int N = 2; double[][] map = new double[M][N]; for(int i =0; i<M; i++ ){ double f1 = Math.random(); int kk = (int)(f1*3.0); for(int j=0; j<N; j++){ double f2 = Math.random(); int ll = (int) (f2*3.0); System.out.println("Node " + i + ": (" + kk + " " + ll + ")"); } } } public static void main(String [] args){ new MatrixLattice(); }}

double f1 = Math.random() generates double number from 0.0 to 1.0

if you write int kk = (int) f1;
then kk will alwys be zero becuase (int) does truncation
however if you mutiply by 3 then it will be 0 or 1 or 2 depending on
what random number we got in thne first place.

Math class has alos method which generates random integers below certain n (say below 3)
If you want you can use that one.

Hi for_Yan I am looking for a solution to a Algorithm problem .. I found on the web.. can you help me out?
I don't know if I am allowed to ask for such help here?

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all. Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET â€¦

Introduction
This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how â€¦

Viewers will learn about if statements in Java and their use
The if statement:
The condition required to create an if statement:
Variations of if statements:
An example using if statements:

Viewers will learn about basic arrays, how to declare them, and how to use them.
Introduction and definition:
Declare an array and cover the syntax of declaring them:
Initialize every index in the created array:
Example/Features of a basic arrâ€¦