Skip to content
580 changes: 291 additions & 289 deletions src/main/java/org/numenta/nupic/Connections.java

Large diffs are not rendered by default.

501 changes: 251 additions & 250 deletions src/main/java/org/numenta/nupic/algorithms/SpatialPooler.java

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/main/java/org/numenta/nupic/model/ProximalDendrite.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void setConnectedSynapsesForTest(Connections c, int[] connectedIndexes) {
* @return
*/
public int[] getConnectedSynapsesDense(Connections c) {
return c.getPotentialPools().getObject(index).getDenseConnections(c);
return c.getPotentialPools().get(index).getDenseConnections(c);
}

/**
Expand All @@ -127,6 +127,6 @@ public int[] getConnectedSynapsesDense(Connections c) {
* @return
*/
public int[] getConnectedSynapsesSparse(Connections c) {
return c.getPotentialPools().getObject(index).getSparseConnections();
return c.getPotentialPools().get(index).getSparseConnections();
}
}
58 changes: 58 additions & 0 deletions src/main/java/org/numenta/nupic/util/BitSetMatrix.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* ---------------------------------------------------------------------
* Numenta Platform for Intelligent Computing (NuPIC)
* Copyright (C) 2014, Numenta, Inc. Unless you have an agreement
* with Numenta, Inc., for a separate license for this software code, the
* following terms and conditions apply:
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* 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, see http://www.gnu.org/licenses.
*
* http://numenta.org/licenses/
* ---------------------------------------------------------------------
*/

package org.numenta.nupic.util;

import java.util.BitSet;

/**
* {@link FlatMatrix} implementation that store booleans in a {@link BitSet}.
*
* @author Jose Luis Martin
*/
public class BitSetMatrix extends FlatMatrixSupport<Boolean> {

private BitSet data;

/**
* @param dimensions
*/
public BitSetMatrix(int[] dimensions) {
this(dimensions, false);
}

public BitSetMatrix(int[] dimensions, boolean useColumnMajorOrdering) {
super(dimensions, useColumnMajorOrdering);
this.data = new BitSet(getSize());
}

@Override
public Boolean get(int index) {
return this.data.get(index);
}

@Override
public BitSetMatrix set(int index, Boolean value) {
this.data.set(index, value);
return this;
}
}
66 changes: 66 additions & 0 deletions src/main/java/org/numenta/nupic/util/FlatArrayMatrix.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/* ---------------------------------------------------------------------
* Numenta Platform for Intelligent Computing (NuPIC)
* Copyright (C) 2014, Numenta, Inc. Unless you have an agreement
* with Numenta, Inc., for a separate license for this software code, the
* following terms and conditions apply:
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* 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, see http://www.gnu.org/licenses.
*
* http://numenta.org/licenses/
* ---------------------------------------------------------------------
*/

package org.numenta.nupic.util;

import java.lang.reflect.Array;
import java.util.Arrays;

/**
* {@link FlatMatrix} implementation that store objects in a flat object array.
*
* @author Jose Luis Martin
*/
public class FlatArrayMatrix<T> extends FlatMatrixSupport<T> {

private T[] data;

public FlatArrayMatrix(int[] dimensions) {
this(dimensions, false);
}

@SuppressWarnings("unchecked")
public FlatArrayMatrix(int[] dimensions, boolean useColumnMajorOrdering) {
super(dimensions, useColumnMajorOrdering);
this.data = (T[]) new Object[getSize()];
}

@Override
public T get(int index) {
return this.data[index];
}

@Override
public FlatArrayMatrix<T> set(int index, T value) {
this.data[index] = value;
return this;
}

/**
* Fill array with value
* @param value
*/
public void fill(T value) {
Arrays.fill(this.data, value);
}

}
55 changes: 55 additions & 0 deletions src/main/java/org/numenta/nupic/util/FlatMatrix.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* ---------------------------------------------------------------------
* Numenta Platform for Intelligent Computing (NuPIC)
* Copyright (C) 2014, Numenta, Inc. Unless you have an agreement
* with Numenta, Inc., for a separate license for this software code, the
* following terms and conditions apply:
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* 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, see http://www.gnu.org/licenses.
*
* http://numenta.org/licenses/
* ---------------------------------------------------------------------
*/

package org.numenta.nupic.util;

/**
* Provides contract for flat matrix implementations.
*
* @author Jose Luis Martin
*/
public interface FlatMatrix<T> extends Matrix<T> {

T get(int index);

FlatMatrix<T> set(int index, T value);

int computeIndex(int[] coordinates);

/**
* Returns the maximum accessible flat index.
* @return the maximum accessible flat index.
*/
int getMaxIndex();

public int computeIndex(int[] coordinates, boolean doCheck);

/**
* Returns an integer array representing the coordinates of the specified index
* in terms of the configuration of this {@code SparseMatrix}.
* @param index the flat index to be returned as coordinates
* @return coordinates
*/
int[] computeCoordinates(int index);

int[] getDimensionMultiples();
}
Loading