Index: lutinmatrix/src/java/org/codelutin/math/matrix/AbstractMatrixND.java diff -u lutinmatrix/src/java/org/codelutin/math/matrix/AbstractMatrixND.java:1.16 lutinmatrix/src/java/org/codelutin/math/matrix/AbstractMatrixND.java:1.17 --- lutinmatrix/src/java/org/codelutin/math/matrix/AbstractMatrixND.java:1.16 Tue Sep 5 12:24:32 2006 +++ lutinmatrix/src/java/org/codelutin/math/matrix/AbstractMatrixND.java Thu Sep 7 09:56:22 2006 @@ -23,9 +23,9 @@ * Created: 29 oct. 2004 * * @author Benjamin Poussin - * @version $Revision: 1.16 $ + * @version $Revision: 1.17 $ * - * Mise a jour: $Date: 2006/09/05 12:24:32 $ + * Mise a jour: $Date: 2006/09/07 09:56:22 $ * par : $Author: bpoussin $ */ @@ -144,7 +144,12 @@ return semantics[dim]; } public void setSemantics(int dim, List sem){ - semantics[dim] = Collections.unmodifiableList(new ArrayList(sem)); + if (!(sem instanceof SemanticList)) { + sem = new SemanticList(sem); + } + // else SemanticList is immutable and can be used in many matrix in + // same time this permit to used same indexOf optimization + semantics[dim] = sem; } public void setName(String name){ this.name = name; Index: lutinmatrix/src/java/org/codelutin/math/matrix/DoubleBigVector.java diff -u /dev/null lutinmatrix/src/java/org/codelutin/math/matrix/DoubleBigVector.java:1.1 --- /dev/null Thu Sep 7 09:56:29 2006 +++ lutinmatrix/src/java/org/codelutin/math/matrix/DoubleBigVector.java Thu Sep 7 09:56:22 2006 @@ -0,0 +1,113 @@ +/* *##% + * Copyright (C) 2005 + * Code Lutin, Cédric Pineau, Benjamin Poussin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * DoubleBigVector.java + * + * Created: 6 octobre 2005 02:54:36 CEST + * + * @author Benjamin POUSSIN + * @version $Revision: 1.1 $ + * + * Last update: $Date: 2006/09/07 09:56:22 $ + * by : $Author: bpoussin $ + */ + +package org.codelutin.math.matrix; + +import java.util.Arrays; + +public class DoubleBigVector implements Vector { // DoubleBigVector + + protected double data[] = null; + + public DoubleBigVector(int capacity){ + data = new double[capacity]; + } + + public int size() { + return data.length; + } + + public double getMaxOccurence() { + return MatrixHelper.maxOccurence(data); + } + + public double getValue(int pos) { + return data[pos]; + } + + public void setValue(int pos, double value) { + data[pos] = value; + } + + public boolean equals(Object o) { + boolean result = false; + if (o instanceof DoubleBigVector) { + DoubleBigVector other = (DoubleBigVector)o; + result = Arrays.equals(this.data, other.data); + } else if (o instanceof Vector) { + Vector other = (Vector)o; + result = true; + for(int i=0; i extends AbstractList implements RandomAccess { + + protected ArrayList datas = null; + protected Map index = null; + + public SemanticList(Collection c) { + datas = new ArrayList(c); + } + + /* (non-Javadoc) + * @see java.util.AbstractList#get(int) + */ + @Override + public T get(int index) { + T result = datas.get(index); + return result; + } + + /* (non-Javadoc) + * @see java.util.AbstractCollection#size() + */ + @Override + public int size() { + int result = datas.size(); + return result; + } + + /* (non-Javadoc) + * @see java.util.AbstractList#indexOf(java.lang.Object) + */ + @Override + public int indexOf(Object o) { + Map index = getIndex(); + Integer result = (Integer)index.get(o); + return result.intValue(); + } + + /** + * @return + */ + private Map getIndex() { + if (index == null) { + index = new HashMap(); + for (int i=0; i