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


Java TDoubleArrayList.toArray方法代码示例

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


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

示例1: computeCPFs

import gnu.trove.list.array.TDoubleArrayList; //导入方法依赖的package包/类
private void computeCPFs ()
{
  isFactorsAdded = true;
  TDoubleArrayList residTmp = new TDoubleArrayList ();
  for (Iterator it = cliques.iterator(); it.hasNext();) {
    UnrolledVarSet clique = (UnrolledVarSet) it.next();
    AbstractTableFactor ptl = clique.tmpl.computeFactor (clique);
    addFactorInternal (clique, ptl);
    clique.tmpl.modifyPotential (this, clique, ptl);
    uvsMap.put (ptl, clique);
    
    // sigh
    LogTableFactor unif = new LogTableFactor (clique);
    residTmp.add (Factors.distLinf (unif, ptl));
  }

  lastResids = residTmp.toArray();
}
 
开发者ID:iamxiatian,项目名称:wikit,代码行数:19,代码来源:ACRF.java

示例2: readSparseVector

import gnu.trove.list.array.TDoubleArrayList; //导入方法依赖的package包/类
private SparseVector readSparseVector (String str, Alphabet dict) throws IOException
{
  TIntArrayList idxs = new TIntArrayList ();
  TDoubleArrayList vals = new TDoubleArrayList ();
  String[] lines = str.split ("\n");
  for (int li = 0; li < lines.length; li++) {
    String line = lines[li];
    if (Pattern.matches ("^\\s*$", line)) continue;

    String[] fields = line.split ("\t");
    int idx;
    if (dict != null) {
      idx = dict.lookupIndex (fields[0]);
    } else {
      idx = Integer.parseInt (fields[0]);
    }

    double val = Double.parseDouble (fields[1]);
    idxs.add (idx);
    vals.add (val);
  }
  return new SparseVector (idxs.toArray(), vals.toArray());
}
 
开发者ID:iamxiatian,项目名称:wikit,代码行数:24,代码来源:ACRF.java

示例3: testSample

import gnu.trove.list.array.TDoubleArrayList; //导入方法依赖的package包/类
public void testSample ()
{
  Variable var = new Variable (Variable.CONTINUOUS);
  Randoms r = new Randoms (2343);
  Factor f = new UniNormalFactor (var, -1.0, 2.0);
  TDoubleArrayList lst = new TDoubleArrayList();
  for (int i = 0; i < 10000; i++) {
    Assignment assn = f.sample (r);
    lst.add (assn.getDouble (var));
  }

  double[] vals = lst.toArray ();
  double mean = MatrixOps.mean (vals);
  double std = MatrixOps.stddev (vals);
  assertEquals (-1.0, mean, 0.025);
  assertEquals (Math.sqrt(2.0), std, 0.01);
}
 
开发者ID:iamxiatian,项目名称:wikit,代码行数:18,代码来源:TestUniNormalFactor.java

示例4: make3dMatrix

import gnu.trove.list.array.TDoubleArrayList; //导入方法依赖的package包/类
private SparseMatrixn make3dMatrix ()
{
  int[] sizes = new int[]{2, 3, 4};
  TIntArrayList idxs = new TIntArrayList ();
  TDoubleArrayList vals = new TDoubleArrayList ();

  for (int i = 0; i < 24; i++) {
    if (i % 3 != 0) {
      idxs.add (i);
      vals.add (2.0 * i);
    }
  }

  SparseMatrixn a = new SparseMatrixn (sizes, idxs.toArray (), vals.toArray ());
  return a;
}
 
开发者ID:iamxiatian,项目名称:wikit,代码行数:17,代码来源:TestSparseMatrixn.java

示例5: calculateLScores

import gnu.trove.list.array.TDoubleArrayList; //导入方法依赖的package包/类
private double[][] calculateLScores(DensityManager dm)
{
	TDoubleArrayList x = new TDoubleArrayList();
	TDoubleArrayList y = new TDoubleArrayList();
	x.add(0.0);
	y.add(0.0);

	for (double r = minR; r < maxR; r += incrementR)
	{
		double l = dm.ripleysLFunction(r);
		x.add(r);
		double score = (r > 0) ? (l - r) / r : 0;
		y.add(score);
	}

	double[][] values = new double[2][];
	values[0] = x.toArray();
	values[1] = y.toArray();
	return values;
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:21,代码来源:DensityImage.java

示例6: SparseMatrixData

import gnu.trove.list.array.TDoubleArrayList; //导入方法依赖的package包/类
/**
 * Copies the data from the given matrix to a new instance of this class.
 */
public SparseMatrixData(HashMatrix matrix) {
	final TIntArrayList rowList = new TIntArrayList();
	final TIntArrayList colList = new TIntArrayList();
	final TDoubleArrayList valList = new TDoubleArrayList();
	matrix.iterate(new MatrixIterator() {
		@Override
		public void next(int row, int col, double val) {
			rowList.add(row);
			colList.add(col);
			valList.add(val);
		}
	});
	this.numberOfEntries = rowList.size();
	this.rows = matrix.rows();
	this.columns = matrix.columns();
	this.rowIndices = rowList.toArray();
	this.columnIndices = colList.toArray();
	this.values = valList.toArray();
}
 
开发者ID:GreenDelta,项目名称:olca-modules,代码行数:23,代码来源:SparseMatrixData.java

示例7: retainMass

import gnu.trove.list.array.TDoubleArrayList; //导入方法依赖的package包/类
public static TableFactor retainMass (DiscreteFactor ptl, double alpha)
{
  int[] idxs = new int [ptl.numLocations ()];
  double[] vals = new double [ptl.numLocations ()];
  for (int i = 0; i < idxs.length; i++) {
    idxs[i] = ptl.indexAtLocation (i);
    vals[i] = ptl.logValue (i);
  }

  RankedFeatureVector rfv = new RankedFeatureVector (new Alphabet(), idxs, vals);
  TIntArrayList idxList = new TIntArrayList ();
  TDoubleArrayList valList = new TDoubleArrayList ();

  double mass = Double.NEGATIVE_INFINITY;
  double logAlpha = Math.log (alpha);
  for (int rank = 0; rank < rfv.numLocations (); rank++) {
    int idx = rfv.getIndexAtRank (rank);
    double val = rfv.value (idx);
    mass = Maths.sumLogProb (mass, val);
    idxList.add (idx);
    valList.add (val);
    if (mass > logAlpha) {
      break;
    }
  }

  int[] szs = computeSizes (ptl);
  SparseMatrixn m = new SparseMatrixn (szs, idxList.toArray (), valList.toArray ());

  TableFactor result = new TableFactor (computeVars (ptl));
  result.setValues (m);

  return result;
}
 
开发者ID:iamxiatian,项目名称:wikit,代码行数:35,代码来源:Factors.java

示例8: checkMeanStd

import gnu.trove.list.array.TDoubleArrayList; //导入方法依赖的package包/类
void checkMeanStd (TDoubleArrayList ell, double mu, double sigma)
{
  double[] vals = ell.toArray ();
  double mean1 = MatrixOps.mean (vals);
  double std1 = MatrixOps.stddev (vals);
  assertEquals (mu, mean1, 0.025);
  assertEquals (sigma, std1, 0.01);
}
 
开发者ID:iamxiatian,项目名称:wikit,代码行数:9,代码来源:TestNormalFactor.java

示例9: testSample

import gnu.trove.list.array.TDoubleArrayList; //导入方法依赖的package包/类
public void testSample ()
{
  Variable var = new Variable (Variable.CONTINUOUS);
  Randoms r = new Randoms (2343);
  Factor f = new BetaFactor (var, 0.7, 0.5);
  TDoubleArrayList lst = new TDoubleArrayList ();
  for (int i = 0; i < 100000; i++) {
    Assignment assn = f.sample (r);
    lst.add (assn.getDouble (var));
  }

  double[] vals = lst.toArray ();
  double mean = MatrixOps.mean (vals);
  assertEquals (0.7 / (0.5 + 0.7), mean, 0.01);
}
 
开发者ID:iamxiatian,项目名称:wikit,代码行数:16,代码来源:TestBetaFactor.java

示例10: testSample2

import gnu.trove.list.array.TDoubleArrayList; //导入方法依赖的package包/类
public void testSample2 ()
{
  Variable var = new Variable (Variable.CONTINUOUS);
  Randoms r = new Randoms (2343);
  Factor f = new BetaFactor (var, 0.7, 0.5, 3.0, 8.0);
  TDoubleArrayList lst = new TDoubleArrayList ();
  for (int i = 0; i < 100000; i++) {
    Assignment assn = f.sample (r);
    lst.add (assn.getDouble (var));
  }

  double[] vals = lst.toArray ();
  double mean = MatrixOps.mean (vals);
  assertEquals (5.92, mean, 0.01);
}
 
开发者ID:iamxiatian,项目名称:wikit,代码行数:16,代码来源:TestBetaFactor.java

示例11: testSample

import gnu.trove.list.array.TDoubleArrayList; //导入方法依赖的package包/类
public void testSample ()
{
  Variable var = new Variable (Variable.CONTINUOUS);
  Randoms r = new Randoms (2343);
  Factor f = new UniformFactor (var, -1.0, 1.5);
  TDoubleArrayList lst = new TDoubleArrayList ();
  for (int i = 0; i < 10000; i++) {
    Assignment assn = f.sample (r);
    lst.add (assn.getDouble (var));
  }

  double[] vals = lst.toArray ();
  double mean = MatrixOps.mean (vals);
  assertEquals (0.25, mean, 0.01);
}
 
开发者ID:iamxiatian,项目名称:wikit,代码行数:16,代码来源:TestUniformFactor.java

示例12: train

import gnu.trove.list.array.TDoubleArrayList; //导入方法依赖的package包/类
@Override
public void train(List<? extends Annotated<OBJECT, ANNOTATION>> data) {
	final TIntIntHashMap nAnnotationCounts = new TIntIntHashMap();
	final TObjectIntHashMap<ANNOTATION> annotationCounts = new TObjectIntHashMap<ANNOTATION>();
	int maxVal = 0;

	for (final Annotated<OBJECT, ANNOTATION> sample : data) {
		final Collection<ANNOTATION> annos = sample.getAnnotations();

		for (final ANNOTATION s : annos) {
			annotationCounts.adjustOrPutValue(s, 1, 1);
		}

		nAnnotationCounts.adjustOrPutValue(annos.size(), 1, 1);

		if (annos.size() > maxVal)
			maxVal = annos.size();
	}

	// build distribution and rng for each annotation
	annotations = new ArrayList<ANNOTATION>();
	final TDoubleArrayList probs = new TDoubleArrayList();
	annotationCounts.forEachEntry(new TObjectIntProcedure<ANNOTATION>() {
		@Override
		public boolean execute(ANNOTATION a, int b) {
			annotations.add(a);
			probs.add(b);
			return true;
		}
	});
	annotationProbability = new EmpiricalWalker(probs.toArray(), Empirical.NO_INTERPOLATION, new MersenneTwister());

	numAnnotations.train(data);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:35,代码来源:IndependentPriorRandomAnnotator.java

示例13: retainLogicalAnd

import gnu.trove.list.array.TDoubleArrayList; //导入方法依赖的package包/类
/**
 * Returns an array of values that test true for all of the
 * specified {@link Condition}s.
 *
 * @param values
 * @param conditions
 * @return
 */
public static double[] retainLogicalAnd(double[] values, Condition<?>[] conditions) {
    TDoubleArrayList l = new TDoubleArrayList();
    for (int i = 0; i < values.length; i++) {
        boolean result = true;
        for (int j = 0; j < conditions.length && result; j++) {
            result &= conditions[j].eval(values[i]);
        }
        if (result) l.add(values[i]);
    }
    return l.toArray();
}
 
开发者ID:numenta,项目名称:htm.java,代码行数:20,代码来源:ArrayUtils.java

示例14: Position

import gnu.trove.list.array.TDoubleArrayList; //导入方法依赖的package包/类
public Position(Portfolio portfolio, String assetName, TDoubleArrayList price, TIntArrayList quantity, TLongArrayList timeMillSec) {
	this( portfolio,  assetName,  price.toArray(),  quantity.toArray(),  timeMillSec.toArray());
}
 
开发者ID:PortfolioEffect,项目名称:PE-HFT-Java,代码行数:4,代码来源:Position.java

示例15: showFrcTimeEvolution

import gnu.trove.list.array.TDoubleArrayList; //导入方法依赖的package包/类
private void showFrcTimeEvolution(String name, double fireNumber, ThresholdMethod thresholdMethod,
		double fourierImageScale, int imageSize)
{
	IJ.showStatus("Calculating FRC time evolution curve...");

	// Sort by time
	results.sort();

	int nSteps = 10;
	int maxT = results.getLastFrame();
	if (maxT == 0)
		maxT = results.size();
	int step = maxT / nSteps;

	TDoubleArrayList x = new TDoubleArrayList();
	TDoubleArrayList y = new TDoubleArrayList();

	double yMin = fireNumber;
	double yMax = fireNumber;

	MemoryPeakResults newResults = new MemoryPeakResults();
	newResults.copySettings(results);
	int i = 0;

	PeakResult[] list = results.toArray();
	for (int t = step; t <= maxT - step; t += step)
	{
		while (i < list.length)
		{
			PeakResult r = list[i];
			if (r.getFrame() <= t)
			{
				newResults.add(r);
				i++;
			}
			else
				break;
		}

		x.add((double) t);

		FIRE f = this.copy();
		FireResult result = f.calculateFireNumber(fourierMethod, samplingMethod, thresholdMethod, fourierImageScale,
				imageSize);
		double fire = (result == null) ? 0 : result.fireNumber;
		y.add(fire);

		yMin = FastMath.min(yMin, fire);
		yMax = FastMath.max(yMax, fire);
	}

	// Add the final fire number
	x.add((double) maxT);
	y.add(fireNumber);

	double[] xValues = x.toArray();
	double[] yValues = y.toArray();

	String units = "px";
	if (results.getCalibration() != null)
	{
		nmPerUnit = results.getNmPerPixel();
		units = "nm";
	}

	String title = name + " FRC Time Evolution";
	Plot2 plot = new Plot2(title, "Frames", "Resolution (" + units + ")", (float[]) null, (float[]) null);
	double range = Math.max(1, yMax - yMin) * 0.05;
	plot.setLimits(xValues[0], xValues[xValues.length - 1], yMin - range, yMax + range);
	plot.setColor(Color.red);
	plot.addPoints(xValues, yValues, Plot.CONNECTED_CIRCLES);

	Utils.display(title, plot);
}
 
开发者ID:aherbert,项目名称:GDSC-SMLM,代码行数:75,代码来源:FIRE.java


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