当前位置: 首页>>代码示例>>Java>>正文


Java DoubleMatrix1D.toArray方法代码示例

本文整理汇总了Java中cern.colt.matrix.DoubleMatrix1D.toArray方法的典型用法代码示例。如果您正苦于以下问题:Java DoubleMatrix1D.toArray方法的具体用法?Java DoubleMatrix1D.toArray怎么用?Java DoubleMatrix1D.toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cern.colt.matrix.DoubleMatrix1D的用法示例。


在下文中一共展示了DoubleMatrix1D.toArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: solveUsingColt

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
/** Solves the system using Colt, to be used only as a fallback when external solver is
 * not available. Justification: construction of matrices is optimized for the 
 * external solver, hence we spend time building them in conformance to the specific
 * format expected by the external solver and then we have to convert them 
 * to Colt format, followed by running Colt itself. Hence all this is
 * extremely slow.
 */  
public void solveUsingColt()
{
	LUDecompositionQuick solver = new LUDecompositionQuick();
	DoubleMatrix2D matrix = toDoubleMatrix2D();
	solver.decompose(matrix);solver.setLU(matrix);
	DoubleMatrix1D result = toDoubleMatrix1D();
	solver.solve(result);result.toArray(j_x);		
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:16,代码来源:LSolver.java

示例2: cube

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
/**
3-d OLAP cube operator; Fills all cells of the given vectors into the given histogram.
If you use hep.aida.ref.Converter.toString(histo) on the result, the OLAP cube of x-"column" vs. y-"column" vs. z-"column", summing the weights "column" will be printed.
For example, aggregate sales by product by region by time.
<p>
Computes the distinct values of x and y and z, yielding histogram axes that capture one distinct value per bin.
Then fills the histogram.
@return the histogram containing the cube.
@throws IllegalArgumentException if <tt>x.size() != y.size() || x.size() != z.size() || x.size() != weights.size()</tt>.
*/
public static hep.aida.IHistogram3D cube(DoubleMatrix1D x, DoubleMatrix1D y, DoubleMatrix1D z, DoubleMatrix1D weights) {
	if (x.size() != y.size() || x.size() != z.size() || x.size() != weights.size()) throw new IllegalArgumentException("vectors must have same size");
	
	double epsilon = 1.0E-9;
	cern.colt.list.DoubleArrayList distinct = new cern.colt.list.DoubleArrayList();
	double[] vals = new double[x.size()];
	cern.colt.list.DoubleArrayList sorted = new cern.colt.list.DoubleArrayList(vals);

	// compute distinct values of x
	x.toArray(vals); // copy x into vals
	sorted.sort();
	cern.jet.stat.Descriptive.frequencies(sorted, distinct, null);
	// since bins are right-open [from,to) we need an additional dummy bin so that the last distinct value does not fall into the overflow bin
	if (distinct.size()>0) distinct.add(distinct.get(distinct.size()-1) + epsilon);
	distinct.trimToSize();
	hep.aida.IAxis xaxis = new hep.aida.ref.VariableAxis(distinct.elements());

	// compute distinct values of y
	y.toArray(vals);
	sorted.sort();
	cern.jet.stat.Descriptive.frequencies(sorted, distinct, null);
	// since bins are right-open [from,to) we need an additional dummy bin so that the last distinct value does not fall into the overflow bin
	if (distinct.size()>0) distinct.add(distinct.get(distinct.size()-1) + epsilon);
	distinct.trimToSize();
	hep.aida.IAxis yaxis = new hep.aida.ref.VariableAxis(distinct.elements());

	// compute distinct values of z
	z.toArray(vals);
	sorted.sort();
	cern.jet.stat.Descriptive.frequencies(sorted, distinct, null);
	// since bins are right-open [from,to) we need an additional dummy bin so that the last distinct value does not fall into the overflow bin
	if (distinct.size()>0) distinct.add(distinct.get(distinct.size()-1) + epsilon);
	distinct.trimToSize();
	hep.aida.IAxis zaxis = new hep.aida.ref.VariableAxis(distinct.elements());

	hep.aida.IHistogram3D histo = new hep.aida.ref.Histogram3D("Cube",xaxis,yaxis,zaxis);
	return histogram(histo,x,y,z,weights);
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:49,代码来源:Statistic.java

示例3: doubleTest36

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
/**
 * Title:        Aero3D<p>
 * Description:  A Program to analyse aeroelestic evects in transonic wings<p>
 * Copyright:    Copyright (c) 1998<p>
 * Company:      PIERSOL Engineering Inc.<p>
 * @author John R. Piersol
 * @version
 */
public static void doubleTest36() {
	double[] testSort = new double[5];
	testSort[0] = 5;
	testSort[1] = Double.NaN;
	testSort[2] = 2;
	testSort[3] = Double.NaN;
	testSort[4] = 1;
	DoubleMatrix1D doubleDense = new DenseDoubleMatrix1D(testSort);
	System.out.println("orig = "+doubleDense);
	doubleDense = doubleDense.viewSorted();
	doubleDense.toArray(testSort);
	System.out.println("sort = "+doubleDense);
	System.out.println("done\n");
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:23,代码来源:TestMatrix2D.java

示例4: permute

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
/**
Modifies the given vector <tt>A</tt> such that it is permuted as specified; Useful for pivoting.
Cell <tt>A[i]</tt> will go into cell <tt>A[indexes[i]]</tt>.
<p>
<b>Example:</b>
<pre>
Reordering
[A,B,C,D,E] with indexes [0,4,2,3,1] yields 
[A,E,C,D,B]
In other words A[0]<--A[0], A[1]<--A[4], A[2]<--A[2], A[3]<--A[3], A[4]<--A[1].

Reordering
[A,B,C,D,E] with indexes [0,4,1,2,3] yields 
[A,E,B,C,D]
In other words A[0]<--A[0], A[1]<--A[4], A[2]<--A[1], A[3]<--A[2], A[4]<--A[3].
</pre>

@param   A   the vector to permute.
@param   indexes the permutation indexes, must satisfy <tt>indexes.length==A.size() && indexes[i] >= 0 && indexes[i] < A.size()</tt>;
@param   work the working storage, must satisfy <tt>work.length >= A.size()</tt>; set <tt>work==null</tt> if you don't care about performance.
@return the modified <tt>A</tt> (for convenience only).
@throws	IndexOutOfBoundsException if <tt>indexes.length != A.size()</tt>.
*/
public DoubleMatrix1D permute(DoubleMatrix1D A, int[] indexes, double[] work) {
	// check validity
	int size = A.size();
	if (indexes.length != size) throw new IndexOutOfBoundsException("invalid permutation");

	/*
	int i=size;
	int a;
	while (--i >= 0 && (a=indexes[i])==i) if (a < 0 || a >= size) throw new IndexOutOfBoundsException("invalid permutation");
	if (i<0) return; // nothing to permute
	*/

	if (work==null || size > work.length) {
		work = A.toArray();
	}
	else {
		A.toArray(work);
	}
	for (int i=size; --i >= 0; ) A.setQuick(i, work[indexes[i]]);
	return A;
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:45,代码来源:Algebra.java


注:本文中的cern.colt.matrix.DoubleMatrix1D.toArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。