本文整理汇总了Java中cern.colt.list.IntArrayList.size方法的典型用法代码示例。如果您正苦于以下问题:Java IntArrayList.size方法的具体用法?Java IntArrayList.size怎么用?Java IntArrayList.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cern.colt.list.IntArrayList
的用法示例。
在下文中一共展示了IntArrayList.size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SparseMultSparseTranspose
import cern.colt.list.IntArrayList; //导入方法依赖的package包/类
static public List<DoubleMatrix1D> SparseMultSparseTranspose(List<DoubleMatrix1D> A,
List<DoubleMatrix1D> B) {
int m = A.size();
int n = A.get(0).size();
int p = B.size();
List<DoubleMatrix1D> C = null;
if (C==null) {
C = new ArrayList<DoubleMatrix1D>();
for (int i = 0; i < m; ++i) {
C.add(new ColtSparseVector(p));
}
}
if (B.get(0).size() != n)
throw new IllegalArgumentException("Matrix2D inner dimensions must agree.");
for (int i = 0; i < m; ++i) {
IntArrayList indexList = new IntArrayList();
DoubleArrayList valueList = new DoubleArrayList();
A.get(i).getNonZeros(indexList, valueList);
for (int j = 0; j < p; ++j) {
if (B.get(j).size() != A.get(i).size())
throw new IllegalArgumentException("Matrix2D inner dimensions must agree.");
double sum = 0.0;
for (int k = 0; k < indexList.size(); ++k) {
int index = indexList.get(k);
double value1 = valueList.get(k);
double value2 = B.get(j).getQuick(index);
if (value1 != 0 || value2 != 0) {
sum += value1 * value2;
}
}
C.get(i).setQuick(j, sum);
}
}
return C;
}
示例2: getSparseTranspose
import cern.colt.list.IntArrayList; //导入方法依赖的package包/类
static public List<DoubleMatrix1D> getSparseTranspose(List<DoubleMatrix1D> A) {
List<DoubleMatrix1D> AT = new ArrayList<DoubleMatrix1D>();
for (int i = 0; i < A.get(0).size(); ++i) {
AT.add(new ColtSparseVector(A.size()));
}
for (int i = 0; i < A.size(); ++i) {
IntArrayList indexList = new IntArrayList();
DoubleArrayList valueList = new DoubleArrayList();
A.get(i).getNonZeros(indexList, valueList);
for (int k = 0; k < indexList.size(); ++k) {
int index = indexList.get(k);
double value = valueList.get(k);
AT.get(index).set(i, value);
}
}
return AT;
}
示例3: productQuick
import cern.colt.list.IntArrayList; //导入方法依赖的package包/类
static public double productQuick(DoubleMatrix1D v1, DoubleMatrix1D v2) {
IntArrayList indexList = new IntArrayList();
DoubleArrayList valueList = new DoubleArrayList();
v1.getNonZeros(indexList, valueList);
double prod = 0.0;
for (int i = 0; i < indexList.size(); ++i) {
double temp = v2.getQuick(indexList.getQuick(i));
if (temp != 0.0) {
prod += valueList.getQuick(i) * temp;
}
}
// for (int i = 0; i < v1.size(); ++i) {
// double temp1 = v1.getQuick(i);
// double temp2 = v2.getQuick(i);
// if (temp1 != 0.0 || temp2 != 0.0) {
// prod += temp1 * temp2;
// }
// }
return prod;
}
示例4: genInputPlaces
import cern.colt.list.IntArrayList; //导入方法依赖的package包/类
private ArrayList genInputPlaces(int ith)
{
ArrayList tuples = new ArrayList();
//get all predecessors
IntArrayList ialPred = getPred(ith, false);
//enumerate all the relevant causual dependencies
for (int i = 0; i < ialPred.size(); i++)
{
int pred = ialPred.get(i);
IntArrayList ialSucc = getSucc(pred, false);
for (int j = 0; j < ialSucc.size(); j++)
{
int succ = ialSucc.get(j);
IntArrayList A = new IntArrayList();
A.add(pred);
IntArrayList B = new IntArrayList();
B.add(succ);
ExpandTree(tuples, A, B, 0, 0);
}
}
return tuple2Place(ith, tuples, 1);
}
示例5: genOutputPlaces
import cern.colt.list.IntArrayList; //导入方法依赖的package包/类
private ArrayList genOutputPlaces(int ith)
{
ArrayList tuples = new ArrayList();
//get all successors
IntArrayList ialSucc = getSucc(ith, false);
//enumerate all the relevant causual dependencies
for (int i = 0; i < ialSucc.size(); i++)
{
int succ = ialSucc.get(i);
IntArrayList ialPred = getPred(succ, false);
for (int j = 0; j < ialPred.size(); j++)
{
int pred = ialPred.get(j);
IntArrayList A = new IntArrayList();
A.add(pred);
IntArrayList B = new IntArrayList();
B.add(succ);
ExpandTree(tuples, A, B, 0, 0);
}
}
return tuple2Place(ith, tuples, 0);
}
示例6: getPredPred
import cern.colt.list.IntArrayList; //导入方法依赖的package包/类
public IntArrayList getPredPred()
{
IntArrayList alTask = new IntArrayList();
for (int i = 0; i < alPred.size(); i++)
{
DoubleSet ds = (DoubleSet) alPred.get(i);
IntArrayList sarPred = ds.getA();
for (int j = 0; j < sarPred.size(); j++)
{
if (!alTask.contains(sarPred.get(j)))
{
alTask.add(sarPred.get(j));
}
}
}
return alTask;
}
示例7: getSuccSucc
import cern.colt.list.IntArrayList; //导入方法依赖的package包/类
public IntArrayList getSuccSucc()
{
IntArrayList alTask = new IntArrayList();
for (int i = 0; i < alSucc.size(); i++)
{
DoubleSet ds = (DoubleSet) alSucc.get(i);
IntArrayList sarSucc = ds.getB();
for (int j = 0; j < sarSucc.size(); j++)
{
if (!alTask.contains(sarSucc.get(j)))
{
alTask.add(sarSucc.get(j));
}
}
}
return alTask;
}
示例8: addNoise
import cern.colt.list.IntArrayList; //导入方法依赖的package包/类
public static void addNoise(DoubleMatrix2D s) {
IntArrayList is = new IntArrayList();
IntArrayList ks = new IntArrayList();
DoubleArrayList vs = new DoubleArrayList();
s.getNonZeros(is, ks, vs);
for (int j=0; j<is.size(); j++) {
int i = is.get(j);
int k = ks.get(j);
double v = vs.get(j);
v = v + (EPSILON * v + REALMIN100) * Math.random();
s.setQuick(i, k, v);
}
}
示例9: toString
import cern.colt.list.IntArrayList; //导入方法依赖的package包/类
/**
* Returns a string representation of the receiver, containing
* the String representation of each key-value pair, sorted ascending by key.
*/
public String toString() {
IntArrayList theKeys = keys();
String tmp = theKeys.toString() + "\n";
theKeys.sort();
StringBuffer buf = new StringBuffer(tmp);
//StringBuffer buf = new StringBuffer();
buf.append("[");
int maxIndex = theKeys.size() - 1;
for (int i = 0; i <= maxIndex; i++) {
int key = theKeys.get(i);
buf.append(String.valueOf(key));
buf.append("->");
buf.append(String.valueOf(get(key)));
if (i < maxIndex) buf.append(", ");
}
buf.append("]");
return buf.toString();
}
示例10: toStringByValue
import cern.colt.list.IntArrayList; //导入方法依赖的package包/类
/**
* Returns a string representation of the receiver, containing
* the String representation of each key-value pair, sorted ascending by value.
*/
public String toStringByValue() {
IntArrayList theKeys = new IntArrayList();
keysSortedByValue(theKeys);
StringBuffer buf = new StringBuffer();
buf.append("[");
int maxIndex = theKeys.size() - 1;
for (int i = 0; i <= maxIndex; i++) {
int key = theKeys.get(i);
buf.append(String.valueOf(key));
buf.append("->");
buf.append(String.valueOf(get(key)));
if (i < maxIndex) buf.append(", ");
}
buf.append("]");
return buf.toString();
}
示例11: toString
import cern.colt.list.IntArrayList; //导入方法依赖的package包/类
/**
* Returns a string representation of the receiver, containing
* the String representation of each key-value pair, sorted ascending by key.
*/
public String toString() {
IntArrayList theKeys = keys();
theKeys.sort();
StringBuffer buf = new StringBuffer();
buf.append("[");
int maxIndex = theKeys.size() - 1;
for (int i = 0; i <= maxIndex; i++) {
int key = theKeys.get(i);
buf.append(String.valueOf(key));
buf.append("->");
buf.append(String.valueOf(get(key)));
if (i < maxIndex) buf.append(", ");
}
buf.append("]");
return buf.toString();
}
示例12: toStringByValue
import cern.colt.list.IntArrayList; //导入方法依赖的package包/类
/**
* Returns a string representation of the receiver, containing
* the String representation of each key-value pair, sorted ascending by value, according to natural ordering.
*/
public String toStringByValue() {
IntArrayList theKeys = new IntArrayList();
keysSortedByValue(theKeys);
StringBuffer buf = new StringBuffer();
buf.append("[");
int maxIndex = theKeys.size() - 1;
for (int i = 0; i <= maxIndex; i++) {
int key = theKeys.get(i);
buf.append(String.valueOf(key));
buf.append("->");
buf.append(String.valueOf(get(key)));
if (i < maxIndex) buf.append(", ");
}
buf.append("]");
return buf.toString();
}
示例13: toString
import cern.colt.list.IntArrayList; //导入方法依赖的package包/类
/**
* Returns a string representation of the receiver, containing
* the String representation of each key-value pair, sorted ascending by key.
*/
public String toString() {
IntArrayList theKeys = keys();
//theKeys.sort();
StringBuffer buf = new StringBuffer();
buf.append("[");
int maxIndex = theKeys.size() - 1;
for (int i = 0; i <= maxIndex; i++) {
int key = theKeys.get(i);
buf.append(String.valueOf(key));
buf.append("->");
buf.append(String.valueOf(get(key)));
if (i < maxIndex) buf.append(", ");
}
buf.append("]");
return buf.toString();
}
示例14: normalise
import cern.colt.list.IntArrayList; //导入方法依赖的package包/类
/**
* Normalizes the sum of the vector elements to 1
* @param vector The vector to normalize
*/
public static void normalise(DoubleMatrix1D vector)
{
double sum = vector.zSum();
if( sum == 0 )
return;
// Treat sparse vectors different
if( vector instanceof SparseDoubleMatrix1D ){
IntArrayList indexList = new IntArrayList();
DoubleArrayList valueList = new DoubleArrayList();
vector.getNonZeros(indexList, valueList);
for(int i=0; i<indexList.size(); i++){
int indexpos = indexList.getQuick(i);
double value = valueList.getQuick(i);
vector.set(indexpos, value/sum );
}
return;
}
// Dense vectors come here
SeqBlas.seqBlas.dscal(1/sum, vector);
}
示例15: setLimits
import cern.colt.list.IntArrayList; //导入方法依赖的package包/类
/**
* Cut a value at its limits
* @param vector The value to evaluate
* @param min The minimal value
* @param max The maximal value
* @return <pre>min <= x <= max</pre>
*/
public static void setLimits(DoubleMatrix1D vector, double min, double max)
{
// Treat sparse vectors different
if( vector instanceof SparseDoubleMatrix1D ){
IntArrayList indexList = new IntArrayList();
DoubleArrayList valueList = new DoubleArrayList();
vector.getNonZeros(indexList, valueList);
for(int i=0; i<indexList.size(); i++){
int indexpos = indexList.getQuick(i);
vector.set(indexpos, MathUtils.setLimits(vector.get(indexpos), min, max));
}
return;
}
else
{
for(int indexpos=0; indexpos<vector.size(); indexpos++)
vector.set(indexpos, MathUtils.setLimits(vector.get(indexpos), min, max));
}
}