Hello Egon,
you are right, a singleton class won't work.
But there are different possibilities ... every molecule should know if the
distance matrix has already been calculated.
If the user changes atoms or bonds you have the choice to reset the calculated
status or let the user decide
with a remove or resetmethod.
1. very simple (saving space):
Let the user decide to calculate distance matrixes as often as needed.
2. simple (saving time):
In every molecule: distMatrix=new int[n][n]; or if not: distMatrix=null;
That's very simple and there should be a flag for every matrix or complex
calculation method, so method 3. would be better.
3. complex (saving time):
I've implemented the distance matrix in JOELib as descriptor, which can be
calculated by
getData("Descriptor_matrix")
or deleted by
deleteData("Descriptor_matrix");
Further methods can simply call getData("Descriptor_matrix") and the distance
matrix will not be calculated again, the user will
obtain the calculated distance matrix.
That maybe a little bit exaggerated for your needs, but i think it could be
usefull to have an efficient Mapinterface
functionality for additional data elements in CDKMolecules. This could be a
distance matrix, adjacent matrix or 'real'
descriptor values, or other objects you want. Something like:
joelib.molecule.GenericDataHolder.
int[][] and double[][] are Java Objects and you can use a Hashtable h with
h.put(intMatrix) and intMatrix=(int[][]) h.get("Distance_matrix")
4. bad:
Another way could be to implement a BitSetState in the
distance matrix method, which can be accessed by the molecule
identifier(number), but thats not a good choice, because there will
be a lot of programming side effects.
Regards, Joerg K. Wegner
"E.L. Willighagen" wrote:
> On Thursday 22 August 2002 15:01, Joerg Kurt Wegner wrote:
> > i would use a static or better a singleton class anyway, because the
> > standard distance matrix is O(N^3) with
> > N=Number of atoms. This class is really often used by descriptor
> > calculation methods and it would be a good choice to calculate the
> > distances only once.
>
> Then what will happen if you have more than one molecule at the same time?
>
> Egon
>
> 
> This sf.net email is sponsored by: OSDN  Tired of that same old
> cell phone? Get a new here for FREE!
> https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
> _______________________________________________
> Cdkdevel mailing list
> Cdkdevel@...
> https://lists.sourceforge.net/lists/listinfo/cdkdevel

Dipl. Chem. Joerg K. Wegner
Univ. Tuebingen, Computer Architecture, Sand 1, D72076 Tuebingen, Germany
Tel. (+49/0) 7071 29 78970, Fax (+49/0) 7071 29 5091
EMail: mailto:wegnerj@...
WWW: http://wwwra.informatik.unituebingen.de
