本文整理汇总了Java中cern.colt.matrix.DoubleMatrix2D.get方法的典型用法代码示例。如果您正苦于以下问题:Java DoubleMatrix2D.get方法的具体用法?Java DoubleMatrix2D.get怎么用?Java DoubleMatrix2D.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cern.colt.matrix.DoubleMatrix2D
的用法示例。
在下文中一共展示了DoubleMatrix2D.get方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSparseMatrix
import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
private DoubleMatrix2D createSparseMatrix(int M, int R, double sparcityPercentage) {
// TODO: add varying scale factor.
// Create sparse matrix.
DoubleMatrix2D D = DoubleFactory2D.sparse.random(M, R);
double[] rowSums = new double[M];
for (int m = 0; m < M; m++) {
for (int r = 0; r < R; r++) {
if (rand.nextDouble() < sparcityPercentage) {
D.set(m, r, 0);
}
rowSums[m] += D.get(m, r);
}
}
// Normalise rows.
for (int m = 0; m < M; m++) {
for (int r = 0; r < R; r++) {
double val = D.get(m, r);
D.set(m, r, val/rowSums[m]);
}
}
return D;
}
示例2: validierung
import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public void validierung(DoubleArrayList trendbereinigtezeitreihe, DoubleMatrix2D matrixPhi, int p) {
double prognosewert = 0;
double realisierungsWert = trendbereinigtezeitreihe.get(trendbereinigtezeitreihe.size() - 1);
Trendgerade trend = new Trendgerade(new double[1]);
realisierungsWert = realisierungsWert + trend.getValue(p);
// Ein Durchlauf findet den Gewichtungsfaktor Phi und den dazu passenden
// Vergangenheitswert.
// Hier wird der Prognosewert für den Zeitpunkt 0 berechnet
for (int t = 0; t < p; t++) {
prognosewert = prognosewert
+ (matrixPhi.get(t, 0) * trendbereinigtezeitreihe.get(trendbereinigtezeitreihe.size() - (t + 2)));
}
prognosewert = prognosewert + trend.getValue(p);
// Berechnung der prozentualen Abweichung
double h = prognosewert / (realisierungsWert / 100);
// Die Variable abweichung enthält die Abweichung in %, abweichung =1
// --> Die Abweichung beträgt 1%
double abweichung = Math.abs(h - 100);
setAbweichung(abweichung);
}
示例3: simplifyRelations
import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public static LogRelations simplifyRelations(LogReader logReader, LogRelations logRelations) {
LogAbstraction logAbstraction = new LogAbstractionImpl(logReader, true);
try {
DoubleMatrix2D parallel = logRelations.getParallelMatrix();
DoubleMatrix2D causalFollower = logRelations.getCausalFollowerMatrix();
DoubleMatrix2D directFollow = logAbstraction.getFollowerInfo(1);
makeBasicRelations(logReader, directFollow, 0.8);
for(int i = 0; i < logRelations.getNumberElements(); i++) {
for(int j = i + 1; j < logRelations.getNumberElements(); j++) {
if(parallel.get(i, j) > 0) {
double ij = directFollow.get(i, j);
double ji = directFollow.get(j, i);
double num = ij - ji;
double den = ij + ji + 1;
double val = Math.abs(num) / den;
if(val > 0.7) {
System.out.println("Changing");
parallel.set(i, j, 0);
parallel.set(j, i, 0);
if(num > 0) {
causalFollower.set(i, j, 1);
}else {
causalFollower.set(j, i, 1);
}
}
}
}
}
} catch (IOException e) {
e.printStackTrace();
}
return logRelations;
}
示例4: identifyExemplars
import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
private void identifyExemplars() {
DoubleMatrix2D ar = this.getAR();
int c = 0;
for (int i = 0; i < n; i++) {
if (ar.get(i, i) > 0) c++;
}
System.out.println("AR diagonal > 0: " + c);
}
示例5: getLogMi
import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
/**
* @param i
* @param mi_YY
* edge features are constrainted to have "=s" and >=s" as the start and end boundaries
*/
public void getLogMi(int i, DoubleMatrix2D mi_YY) {
double DEFAULT_VALUE = RobustMath.LOG0;
mi_YY.assign(DEFAULT_VALUE);
for (Iterator<Feature> iter = edgeFeatures.get(i).iterator(); iter.hasNext(); ) {
Feature f = iter.next();
double oldVal = mi_YY.get(f.yprev(), f.y());
if (oldVal == DEFAULT_VALUE)
oldVal = 0;
mi_YY.set(f.yprev(),f.y(),oldVal+lambda[f.index()]*f.value());
}
}
示例6: matrix2dDoubleArray
import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
static double[][] matrix2dDoubleArray(DoubleMatrix2D mat)
{
double[][] array = new double[mat.columns()][mat.rows()];
for (int i = 0; i < mat.rows(); i++ )
{;
for (int j = 0; j < mat.columns(); j ++)
array[j][i] = mat.get(i, j);
}
return array;
}
示例7: makeBasicRelations
import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
private static void makeBasicRelations(LogReader log, DoubleMatrix2D causalSuccession, double causalityFall) {
events = log.getLogSummary().getLogEvents();
longRangeSuccessionCount = DoubleFactory2D.dense.make(events.size(), events.size(), 0);
log.reset();
while (log.hasNext()) {
ProcessInstance pi = log.next();
AuditTrailEntries ate = pi.getAuditTrailEntries();
int i = 0;
boolean terminate = false;
while (!terminate) {
ate.reset();
// Skip the first i entries of the trace
for (int j = 0; j < i; j++) {
ate.next();
}
// Work with the other entries.
AuditTrailEntry begin = ate.next();
// Find the correct row of the matices
int row = events.findLogEventNumber(begin.getElement(),
begin.getType());
int distance = 0;
boolean foundSelf = false;
HNSubSet done = new HNSubSet();
terminate = (!ate.hasNext());
while (ate.hasNext() && (!foundSelf)) {
AuditTrailEntry end = ate.next();
int column = events.findLogEventNumber(end.
getElement(),
end.getType()
);
foundSelf = (row == column);
distance++;
if (done.contains(column)) {
continue;
}
done.add(column);
// update long range matrix
longRangeSuccessionCount.set(row, column, longRangeSuccessionCount.get(row,
column) + 1);
// update causal matrix
// System.out.println("Change from " + causalSuccession.get(row,
// column) + " to " + causalSuccession.get(row,
// column) + Math.pow(causalityFall, distance - 1));
causalSuccession.set(row, column, causalSuccession.get(row,
column) + Math.pow(causalityFall, distance - 1));
}
i++;
}
}
// calculate causalSuccesion (==> not yet used during heuristics process mining!!!
for (int i = 0; i < causalSuccession.rows(); i++) {
for (int j = 0; j < causalSuccession.columns(); j++) {
if (causalSuccession.get(i, j) == 0) {
continue;
}
causalSuccession.set(i, j, causalSuccession.get(i, j) /
longRangeSuccessionCount.get(i, j));
}
}
}
示例8: computeStationaryDistribution
import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
private void computeStationaryDistribution(double[] statDistr) {
// // Uses an eigendecomposition and matrix inverse
// DoubleMatrix2D mat = new DenseDoubleMatrix2D(numBaseModel, numBaseModel);
// int index = 0;
// for (int i = 0; i < numBaseModel; ++i) {
// for (int j = i + 1; j < numBaseModel; ++j) {
// mat.set(i, j, switchingRates.getParameterValue(index));
// index++;
// }
// }
// for (int j = 0; j < numBaseModel; ++j) {
// for (int i = j + 1; i < numBaseModel; ++i) {
// mat.set(i, j, switchingRates.getParameterValue(index));
// index++;
// }
// }
// for (int i = 0; i < numBaseModel; ++i) {
// double rowTotal = 0.0;
// for (int j = 0; j < numBaseModel; ++j) {
// if (i != j) {
// rowTotal += mat.get(i,j);
// }
// }
// mat.set(i,i, -rowTotal);
// }
//
// EigenvalueDecomposition ed = new EigenvalueDecomposition(mat);
// DoubleMatrix2D eigenVectors = ed.getV();
// DoubleMatrix2D b = alg.mult(eigenVectors, alg.mult(d, alg.inverse(eigenVectors)));
//
// for (int i = 0; i < numBaseModel; ++i) {
// statDistr[i] = b.get(0,i);
// }
// System.err.println(new Vector(statDistr));
if (allRatesAreZero(switchingRates)) {
return;
}
// Uses an LU decomposition to solve Q^t \pi = 0 and \sum \pi_i = 1
DoubleMatrix2D mat2 = new DenseDoubleMatrix2D(numBaseModel + 1, numBaseModel);
int index2 = 0;
for (int i = 0; i < numBaseModel; ++i) {
for (int j = i + 1; j < numBaseModel; ++j) {
mat2.set(j, i, switchingRates.getParameterValue(index2)); // Transposed
index2++;
}
}
for (int j = 0; j < numBaseModel; ++j) {
for (int i = j + 1; i < numBaseModel; ++i) {
mat2.set(j, i, switchingRates.getParameterValue(index2)); // Transposed
index2++;
}
}
for (int i = 0; i < numBaseModel; ++i) {
double rowTotal = 0.0;
for (int j = 0; j < numBaseModel; ++j) {
if (i != j) {
rowTotal += mat2.get(j, i); // Transposed
}
}
mat2.set(i, i, -rowTotal);
}
// Add row for sum-to-one constraint
for (int i = 0; i < numBaseModel; ++i) {
mat2.set(numBaseModel, i, 1.0);
}
LUDecomposition decomp = new LUDecomposition(mat2);
DoubleMatrix2D x = new DenseDoubleMatrix2D(numBaseModel + 1, 1);
x.set(numBaseModel, 0, 1.0);
DoubleMatrix2D y = decomp.solve(x);
for (int i = 0; i < numBaseModel; ++i) {
statDistr[i] = y.get(i, 0);
}
//System.err.println(new Vector(statDistr));
}
示例9: checkIncestConditionParents
import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public static SparseDoubleMatrix2D checkIncestConditionParents( DoubleMatrix2D signatureNodeIncestVector,
DoubleMatrix2D functionNodeIncestVector,
SparseDoubleMatrix2D signatureAdjacencyMatrix,
SparseDoubleMatrix2D functionAdjacencyMatrix,
int[] signatureDepths,
int[] functionDepths,
int depth,
SparseDoubleMatrix2D candidateList) {
SparseDoubleMatrix2D signatureSelector = new SparseDoubleMatrix2D(1, signatureDepths.length);
SparseDoubleMatrix2D functionSelector = new SparseDoubleMatrix2D(1, functionDepths.length);
for(int i=0; i<signatureNodeIncestVector.size(); ++i) {
if(signatureNodeIncestVector.get(0, i) == 0.0)
continue;
signatureSelector.assign(0.0);
signatureSelector.set(0, i, 1.0);
DoubleMatrix2D signatureNodeParentVector = Algebra.DEFAULT.mult(signatureSelector, Algebra.DEFAULT.transpose(signatureAdjacencyMatrix));
// only bipartite match on incest parents
for(int iParent = 0; iParent < signatureNodeParentVector.columns(); ++iParent) {
if(signatureNodeParentVector.get(0, iParent) > 0 && signatureDepths[iParent] != depth) {
signatureNodeParentVector.set(0, iParent, 0.0);
}
}
int signatureIncestParentCount = signatureNodeParentVector.cardinality();
for(int j=0; j<functionNodeIncestVector.size(); ++j) {
if(candidateList.get(i, j) == 0.0)
continue;
functionSelector.assign(0.0);
functionSelector.set(0, j, 1.0);
DoubleMatrix2D functionNodeParentVector = Algebra.DEFAULT.mult(functionSelector, Algebra.DEFAULT.transpose(functionAdjacencyMatrix));
// only bipartite match on incest parents
for(int iParent = 0; iParent < functionNodeParentVector.columns(); ++iParent) {
if(functionNodeParentVector.get(0, iParent) > 0 && functionDepths[iParent] != depth) {
functionNodeParentVector.set(0, iParent, 0.0);
}
}
int functionIncestParentCount = functionNodeParentVector.cardinality();
// bipartite matching, if !sufficient
if( candidateList.get(i, j) > 0 && (signatureIncestParentCount > functionIncestParentCount ||
!bipartiteMatchingVector(candidateList, signatureNodeParentVector, functionNodeParentVector, signatureDepths, functionDepths))) {
// remove candidacy
candidateList.set(i, j, 0.0);
}
}
}
return candidateList;
}
示例10: checkPreviouslyVisitedChildren
import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public static SparseDoubleMatrix2D checkPreviouslyVisitedChildren( IntArrayList signatureNonZeros,
IntArrayList functionNonZeros,
SparseDoubleMatrix2D signatureAdjacencyMatrix,
SparseDoubleMatrix2D functionAdjacencyMatrix,
int[] signatureDepths,
int[] functionDepths,
SparseDoubleMatrix2D candidateList) {
SparseDoubleMatrix2D signatureSelector = new SparseDoubleMatrix2D(1, signatureDepths.length);
SparseDoubleMatrix2D functionSelector = new SparseDoubleMatrix2D(1, functionDepths.length);
// reduce candidacy based on previously visited children
for(int i=0; i<signatureNonZeros.size(); ++i) {
// for node N, this sets the Nth bit of the vector to 1.0
signatureSelector.assign(0.0);
signatureSelector.set(0, signatureNonZeros.get(i), 1.0);
// get children at depth <= current
DoubleMatrix2D signatureNodeChildVector = Algebra.DEFAULT.mult(signatureSelector, signatureAdjacencyMatrix);
// remove signature node's unvisited children
for(int iChild = 0; iChild < signatureNodeChildVector.columns(); ++iChild) {
if(signatureNodeChildVector.get(0, iChild) > 0 && signatureDepths[iChild] == -1) { // for the oposite conditional && signatureDepths[iChild] <= depth) {
signatureNodeChildVector.set(0, iChild, 0.0);
}
}
int signatureVisitedChildCount = signatureNodeChildVector.cardinality();
for(int j=0; j<functionNonZeros.size(); ++j) {
functionSelector.assign(0.0);
functionSelector.set(0, functionNonZeros.get(j), 1.0);
// get children at depth <= current
DoubleMatrix2D functionNodeChildVector = Algebra.DEFAULT.mult(functionSelector, functionAdjacencyMatrix);
// remove function node's unvisited children
for(int iChild = 0; iChild < functionNodeChildVector.columns(); ++iChild) {
if(functionNodeChildVector.get(0, iChild) > 0 && functionDepths[iChild] == -1) { // for the oposite conditional && functionDepths[iChild] <= depth) {
functionNodeChildVector.set(0, iChild, 0.0);
}
}
int functionVisitedChildCount = functionNodeChildVector.cardinality();
// bipartite matching, if !sufficient
if( candidateList.get(signatureNonZeros.get(i), functionNonZeros.get(j)) > 0 &&
(signatureVisitedChildCount > functionVisitedChildCount ||
!bipartiteMatchingVector(candidateList, signatureNodeChildVector, functionNodeChildVector, signatureDepths, functionDepths))) {
// remove candidacy
candidateList.set(signatureNonZeros.get(i), functionNonZeros.get(j), 0.0);
}
}
}
return candidateList;
}
示例11: bipartiteMatchingVector
import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public static boolean bipartiteMatchingVector(DoubleMatrix2D candidateList, DoubleMatrix2D signatureNodeVector, DoubleMatrix2D functionNodeVector, int[] signatureDepths, int[] functionDepths) {
UndirectedGraph<String, DefaultEdge> g = new SimpleGraph<String, DefaultEdge>(DefaultEdge.class);
IntArrayList signatureNonZeros = new IntArrayList();
IntArrayList functionNonZeros = new IntArrayList();
IntArrayList unusedInt = new IntArrayList();
DoubleArrayList unusedDouble = new DoubleArrayList();
// get set column indices for signature vector and function vector
signatureNodeVector.getNonZeros(unusedInt, signatureNonZeros, unusedDouble);
functionNodeVector.getNonZeros(unusedInt, functionNonZeros, unusedDouble);
List<String> signatureIdcs = new ArrayList<String>();
List<String> functionIdcs = new ArrayList<String>();
int signatureNodeCount = 0;
// add signature nodes graph
for(int i=0; i<signatureNonZeros.size(); ++i) {
int signatureIdx = signatureNonZeros.get(i);
if(signatureDepths[signatureIdx] != -1) {
signatureIdcs.add("s"+signatureIdx);
g.addVertex("s"+signatureIdx);
signatureNodeCount++;
}
}
// add function nodes graph
for(int j=0; j<functionNonZeros.size(); ++j) {
int functionIdx = functionNonZeros.get(j);
if(functionDepths[functionIdx] != -1) {
functionIdcs.add("f"+functionNonZeros.get(j));
g.addVertex("f"+functionNonZeros.get(j));
}
}
// add edges
for(int i=0; i<signatureNonZeros.size(); ++i) {
for(int j=0; j<functionNonZeros.size(); ++j) {
if(candidateList.get(signatureNonZeros.get(i), functionNonZeros.get(j)) != 0) {
g.addEdge("s"+signatureNonZeros.get(i), "f"+functionNonZeros.get(j));
}
}
}
// define sets
Set<String> p1 = new HashSet<String>(signatureIdcs);
Set<String> p2 = new HashSet<String>(functionIdcs);
// bipartite matching!
HopcroftKarpBipartiteMatching<String, DefaultEdge> alg =
new HopcroftKarpBipartiteMatching<String, DefaultEdge>(g, p1, p2);
Set<DefaultEdge> match = alg.getMatching();
// sat || unsat
if(match.size() == signatureNodeCount) {
return true;
} else {
return false;
}
}
示例12: normalize
import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public void normalize() {
// System.out.println(adjacencyMatrix);
int adjacencyMatrixSize = adjacencyMatrix.columns();
if(adjacencyMatrixSize < 1)
return;
DoubleMatrix2D selector = new SparseDoubleMatrix2D(1, adjacencyMatrixSize);
selector.set(0, 0, 1.0);
// System.out.println(selector);
// get vertices reachable from V0
int cardinality = selector.cardinality();
int lastCardinality = 0;
DoubleDoubleFunction merge = new DoubleDoubleFunction() {
public double apply(double a, double b) {
return (a > 0 || b > 0) ? 1 : 0;
}
};
while(cardinality != lastCardinality) {
lastCardinality = cardinality;
// selector = Algebra.DEFAULT.mult(selector, adjacencyMatrix);
selector.assign(Algebra.DEFAULT.mult(selector, adjacencyMatrix), merge);
// System.out.println(selector);
cardinality = selector.cardinality();
}
// System.out.println(selector);
if(cardinality == adjacencyMatrixSize) {
return;
}
// IntArrayList nonZeros = new IntArrayList();
// IntArrayList unusedInt = new IntArrayList();
// DoubleArrayList unusedDouble = new DoubleArrayList();
// selector.getNonZeros(unusedInt, nonZeros, unusedDouble);
// SparseDoubleMatrix2D reduced = new SparseDoubleMatrix2D(adjacencyMatrix.viewSelection(nonZeros.elements(), nonZeros.elements()).toArray());
SparseDoubleMatrix2D reduced = new SparseDoubleMatrix2D(cardinality, cardinality);
int iCurrentVertex = 0;
for(int i=0; i<adjacencyMatrixSize; ++i) {
if(selector.get(0, i) != 0.0) {
int jCurrentVertex = 0;
for(int j=0; j<adjacencyMatrixSize; ++j) {
if(selector.get(0, j) != 0.0){
reduced.set(iCurrentVertex, jCurrentVertex, adjacencyMatrix.get(i, j));
++jCurrentVertex;
}
}
++iCurrentVertex;
}
}
// System.out.println(reduced);
// System.out.println("=======");
adjacencyMatrix = reduced;
vertexCount = adjacencyMatrix.columns();
edgeCount = adjacencyMatrix.cardinality();
}
示例13: normalize
import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public void normalize() {
// System.out.println(adjacencyMatrix);
int adjacencyMatrixSize = adjacencyMatrix.columns();
if(adjacencyMatrixSize < 1)
return;
DoubleMatrix2D selector = new SparseDoubleMatrix2D(1, adjacencyMatrixSize);
selector.set(0, 0, 1.0);
// System.out.println(selector);
// get vertices reachable from V0
int cardinality = selector.cardinality();
int lastCardinality = 0;
DoubleDoubleFunction merge = new DoubleDoubleFunction() {
public double apply(double a, double b) {
return (a > 0 || b > 0) ? 1 : 0;
}
};
while(cardinality != lastCardinality) {
lastCardinality = cardinality;
// selector = Algebra.DEFAULT.mult(selector, adjacencyMatrix);
selector.assign(Algebra.DEFAULT.mult(selector, adjacencyMatrix), merge);
// System.out.println(selector);
cardinality = selector.cardinality();
}
// System.out.println(selector);
if(cardinality == adjacencyMatrixSize) {
return;
}
// IntArrayList nonZeros = new IntArrayList();
// IntArrayList unusedInt = new IntArrayList();
// DoubleArrayList unusedDouble = new DoubleArrayList();
// selector.getNonZeros(unusedInt, nonZeros, unusedDouble);
// SparseDoubleMatrix2D reduced = new SparseDoubleMatrix2D(adjacencyMatrix.viewSelection(nonZeros.elements(), nonZeros.elements()).toArray());
SparseDoubleMatrix2D reduced = new SparseDoubleMatrix2D(cardinality, cardinality);
int iCurrentVertex = 0;
for(int i=0; i<adjacencyMatrixSize; ++i) {
if(selector.get(0, i) != 0.0) {
int jCurrentVertex = 0;
for(int j=0; j<adjacencyMatrixSize; ++j) {
if(selector.get(0, j) != 0.0){
reduced.set(iCurrentVertex, jCurrentVertex, adjacencyMatrix.get(i, j));
++jCurrentVertex;
}
}
++iCurrentVertex;
}
}
// System.out.println(reduced);
// System.out.println("=======");
adjacencyMatrix = reduced;
vertexCount = adjacencyMatrix.columns();
edgeCount = adjacencyMatrix.cardinality();
}