J
John Fourkiotis
Hello to everyone,
as a part of a big project, a Matrix (2D) class is needed that can handle
both double and complex values. For example, we should be able to write:
Matrix someMatrix = new ....
.....
someMatrix[0,3] = new Scalar(3); // [0,3] = 3, a double value
someMatrix[0,2] = new Complex(4, -2) // [0,2] = 4-2i, complex value
Although speed is not the top of my concerns, is there an efficient but
elegant way of accomplishing this ? I wouldnt like to use an object[] array,
ie
class Matrix
{
private Object[] data;
....
}
Can generics help with this kind of problem ?
Thanx
as a part of a big project, a Matrix (2D) class is needed that can handle
both double and complex values. For example, we should be able to write:
Matrix someMatrix = new ....
.....
someMatrix[0,3] = new Scalar(3); // [0,3] = 3, a double value
someMatrix[0,2] = new Complex(4, -2) // [0,2] = 4-2i, complex value
Although speed is not the top of my concerns, is there an efficient but
elegant way of accomplishing this ? I wouldnt like to use an object[] array,
ie
class Matrix
{
private Object[] data;
....
}
Can generics help with this kind of problem ?
Thanx