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


Java DoubleMatrix1D.assign方法代码示例

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


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

示例1: the

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
/** 
Generates and returns the (economy-sized) orthogonal factor <tt>Q</tt>.
@return <tt>Q</tt>
*/
public DoubleMatrix2D getQ () {
	cern.jet.math.Functions F = cern.jet.math.Functions.functions;
	DoubleMatrix2D Q = QR.like();
	//double[][] Q = X.getArray();
	for (int k = n-1; k >= 0; k--) {
		DoubleMatrix1D QRcolk = QR.viewColumn(k).viewPart(k,m-k);
		Q.setQuick(k,k, 1);
		for (int j = k; j < n; j++) {
			if (QR.getQuick(k,k) != 0) {
				DoubleMatrix1D Qcolj = Q.viewColumn(j).viewPart(k,m-k);
				double s = QRcolk.zDotProduct(Qcolj);
				s = -s / QR.getQuick(k,k);
				Qcolj.assign(QRcolk, F.plusMult(s));
			}
		}
	}
	return Q;
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:23,代码来源:QRDecomposition.java

示例2: computeLogMi

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
static boolean computeLogMi(FeatureGenerator featureGen, double lambda[], 
        DoubleMatrix2D Mi_YY,
        DoubleMatrix1D Ri_Y, boolean takeExp,boolean reuseM, boolean initMDone) {
    
    if (reuseM && initMDone) {
        Mi_YY = null;
    } else {
        initMDone = false;
    }
    if (Mi_YY != null) Mi_YY.assign(0);
    Ri_Y.assign(0);
    initMDone = computeLogMiInitDone(featureGen,lambda,Mi_YY,Ri_Y,0);
    if (takeExp) {
        for(int r = Ri_Y.size()-1; r >= 0; r--) {
            Ri_Y.setQuick(r,expE(Ri_Y.getQuick(r)));
            if (Mi_YY != null)
                for(int c = Mi_YY.columns()-1; c >= 0; c--) {
                    Mi_YY.setQuick(r,c,expE(Mi_YY.getQuick(r,c)));
                }
        }
    }
    return initMDone;
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:24,代码来源:Trainer.java

示例3: dsymv

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
public void dsymv(boolean isUpperTriangular, double alpha, DoubleMatrix2D A, DoubleMatrix1D x, double beta, DoubleMatrix1D y) {
	if (isUpperTriangular) A = A.viewDice();
	Property.DEFAULT.checkSquare(A);
	int size = A.rows();
	if (size != x.size() || size!=y.size()) {
		throw new IllegalArgumentException(A.toStringShort() + ", " + x.toStringShort() + ", " + y.toStringShort());
	}
	DoubleMatrix1D tmp = x.like();
	for (int i = 0; i < size; i++) {
		double sum = 0;
		for (int j = 0; j <= i; j++) {
			sum += A.getQuick(i,j) * x.getQuick(j);
		}
		for (int j = i + 1; j < size; j++) {
			sum += A.getQuick(j,i) * x.getQuick(j);
		}
		tmp.setQuick(i, alpha * sum + beta * y.getQuick(i));
	}
	y.assign(tmp);
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:21,代码来源:SeqBlas.java

示例4: normalizePuz

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
/**
 * Normalizes matrix of p(z|u) such that \forall_u: \sum_z p(z|u) = 1.
 *
 * @param pu_z normalized matrix of p(z|u)
 */
@Override
protected void normalizePuz(DoubleMatrix2D pu_z) {
    for (int u = 0; u < pu_z.rows(); u++) {
        DoubleMatrix1D tmp = pu_z.viewRow(u);
        double norm = tmp.aggregate(Functions.plus, Functions.identity);
        if (norm != 0.0) {
            tmp.assign(Functions.mult(1 / norm));
        }
    }
}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:16,代码来源:CPLSAIAFactorizationModelFactory.java

示例5: normalizePiz

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
/**
 * Normalizes matrix of p(i|z) such that \forall_z: \sum_i p(i|z) = 1.
 *
 * @param piz normalized matrix of p(i|z)
 */
@Override
protected void normalizePiz(DoubleMatrix2D piz) {
    for (int i = 0; i < piz.columns(); i++) {
        DoubleMatrix1D tmp = piz.viewColumn(i);
        double norm = tmp.aggregate(Functions.plus, Functions.identity);
        if (norm != 0.0) {
            tmp.assign(Functions.mult(1 / norm));
        }
    }
}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:16,代码来源:CPLSAIAFactorizationModelFactory.java

示例6: normalizePuz

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
/**
 * Normalizes matrix of p(z|u) such that \forall_z: \sum_u p(z|u) = 1.
 *
 * @param pu_z normalized matrix of p(z|u)
 */
protected void normalizePuz(DoubleMatrix2D pu_z) {
    for (int z = 0; z < pu_z.columns(); z++) {
        final DoubleMatrix1D pu_Z = pu_z.viewColumn(z);
        pu_Z.assign(mult(1 / pu_Z.aggregate(plus, identity)));
    }
}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:12,代码来源:PLSAFactorizer.java

示例7: zMult

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
/**
 * Linear algebraic matrix-vector multiplication; <tt>z = A * y</tt>.
 * <tt>z[i] = alpha*Sum(A[i,j] * y[j]) + beta*z[i], i=0..A.rows()-1, j=0..y.size()-1</tt>.
 * Where <tt>A == this</tt>.
 * @param y the source vector.
 * @param z the vector where results are to be stored.
 * 
 * @throws IllegalArgumentException if <tt>A.columns() != y.size() || A.rows() > z.size())</tt>.
 */
protected void zMult(final DoubleMatrix1D y, final DoubleMatrix1D z, cern.colt.list.IntArrayList nonZeroIndexes, DoubleMatrix1D[] allRows, final double alpha, final double beta) {
	if (columns != y.size() || rows > z.size())	
		throw new IllegalArgumentException("Incompatible args: "+toStringShort()+", "+y.toStringShort()+", "+z.toStringShort());

	z.assign(cern.jet.math.Functions.mult(beta/alpha));
	for (int i = indexes.length; --i >= 0; ) {
		if (indexes[i] != null) {
			for (int k = indexes[i].size(); --k >= 0; ) {
				int j = indexes[i].getQuick(k);
				double value = values[i].getQuick(k);
				z.setQuick(i,z.getQuick(i) + value * y.getQuick(j));
			}
		}
	}
		
	z.assign(cern.jet.math.Functions.mult(alpha));
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:27,代码来源:RCMDoubleMatrix2D.java

示例8: logMult

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
public static DoubleMatrix1D logMult(DoubleMatrix2D M, DoubleMatrix1D y, DoubleMatrix1D z, double alpha, double beta, boolean transposeA) {
        // z = alpha * A * y + beta*z
        double lalpha = 0;
        if (alpha != 1)
            lalpha = Math.log(alpha);
        if (beta != 0) {
            if (beta != 1) {
                double lbeta = Math.log(beta);
                for (int i = 0; i < z.size(); z.set(i,z.get(i)+lbeta),i++);
            }
        } else {
            z.assign(RobustMath.LOG0);
        }
        // in log domain this becomes: 
        logMult.M = M;
        logMult.z = z;
        logMult.lalpha = lalpha;
        logMult.transposeA = transposeA;
        logMult.y = y;
        logMult.cnt=0;
        M.forEachNonZero(logMult);
//      System.out.println("Matrix "+M.size()+" "+M.columns()+ " "+logMult.cnt);
        return z;
    }
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:25,代码来源:RobustMath.java

示例9: initLogMi

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
public static double initLogMi(double defaultValue, Iterator constraints,
        DoubleMatrix2D Mi, DoubleMatrix1D Ri) {
    if (constraints != null) {
        defaultValue = RobustMath.LOG0;
        if (Mi != null) Mi.assign(defaultValue);
        Ri.assign(defaultValue);
        for (; constraints.hasNext();) {
            Constraint constraint = (Constraint)constraints.next();
            if (constraint.type() == Constraint.ALLOW_ONLY) {
                RestrictConstraint cons = (RestrictConstraint)constraint;
                /*
                 for (int c = cons.numAllowed()-1; c >= 0; c--) {
                 Ri.set(cons.allowed(c),0);
                 }
                 */
                for (cons.startScan(); cons.hasNext();) {
                    cons.advance();
                    int y = cons.y();
                    int yprev = cons.yprev();
                    if (yprev < 0) {
                        Ri.set(y,0);
                    } else {
                        if (Mi != null) Mi.set(yprev,y,0);
                    }
                }
            }
        }
    } else {
        if (Mi != null) Mi.assign(defaultValue);
        Ri.assign(defaultValue);    
    } 
    return defaultValue;
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:34,代码来源:Trainer.java

示例10: CalculatePortfolioStandardDeviation

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
/**
  * Compute the stock portfolio return standard deviation (sigma, a number).
  * 
  * A. Compute the stock portfolio covariance matrix:
  *   1. Calculate log-returns: aR(t) = log(p(t)/p(t-1)).
  *   2. Estimate the log-returns: maR(t) = d*aR(t) + (1-d)*maR(t-1) where d is memory.
  *   3. Estimate the covariance matrix:
  *      Cov(t) = d*(outer(aR(t)-maR(t),aR(t)-maR(t)) + (1-d)*Cov(t-1).
  * 
  * B. Compute the deviation of portfolio returns:
  *   1. Variance sigma**2 of the stock portfolio : sigma**2 = w**T.Cov.w 
  *   2. Assume, for simplicity, that loans have same variance.
  *   3. Return sqrt(sigma**2 + (1-sum(w))**2*s**2).
  */
static double CalculatePortfolioStandardDeviation(
   int numberOfFirmsToInvestIn,
   List<Double> firmMarketValuesNow,
   List<Double> firmMarketValuesLast,
   double[] firmStockWeights,
   double covarianceAdaptationRate,
   DoubleMatrix1D meanLogStockReturns,
   DoubleMatrix2D meanStockCovarianceMatrix
   ) {
   Algebra algebra = new Algebra();
   DenseDoubleMatrix1D logOfStockReturns = new DenseDoubleMatrix1D(numberOfFirmsToInvestIn);
   for (int i = 0; i < numberOfFirmsToInvestIn; ++i) {
      double presentOverLastValue = (firmMarketValuesNow.get(i) / firmMarketValuesLast.get(i));
      if (presentOverLastValue > 0.) 
         logOfStockReturns.set(i, Math.log(presentOverLastValue));
      else logOfStockReturns.set(i, 0.);
   }
   
   meanLogStockReturns.assign(
      logOfStockReturns.copy().assign(Functions.mult(covarianceAdaptationRate))
      .assign(meanLogStockReturns.copy().assign(Functions.mult(1. - covarianceAdaptationRate)), 
         Functions.plus));
   
   logOfStockReturns.assign(meanLogStockReturns, Functions.minus);
   DoubleMatrix2D newCovMatrix = 
      DoubleFactory2D.dense.make(numberOfFirmsToInvestIn, numberOfFirmsToInvestIn);
   algebra.multOuter(logOfStockReturns, logOfStockReturns, newCovMatrix);
   
   meanStockCovarianceMatrix.assign(
      newCovMatrix.copy().assign(Functions.mult(covarianceAdaptationRate))
      .assign(meanStockCovarianceMatrix.copy().assign(
         Functions.mult(1. - covarianceAdaptationRate)), Functions.plus));
   
   DoubleMatrix1D stockWeightsVector =
      new DenseDoubleMatrix1D(firmStockWeights);
   final double
      loanWeight = (1. - stockWeightsVector.zSum()),
      sigmaSquared = algebra.mult(stockWeightsVector,
         algebra.mult(meanStockCovarianceMatrix, stockWeightsVector));
   
   return Math.sqrt(sigmaSquared * (1. + loanWeight * loanWeight));
}
 
开发者ID:crisis-economics,项目名称:CRISIS,代码行数:57,代码来源:ValueAtRiskLeverageTargetAlgorithm.java

示例11: calculateMdR

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
private double calculateMdR(final double[] fitness) {
    DoubleMatrix1D theta = DoubleFactory1D.dense.make(20, 0.0);
    for (int i = 0; i < fitness.length; i++) theta.setQuick(i, fitness[i]);

    theta.assign(Functions.exp);
    theta.assign(Functions.div(theta.zSum()));

    return alpha * theta.aggregate(Functions.plus, Functions.log);
}
 
开发者ID:tamuri,项目名称:swmutsel,代码行数:10,代码来源:DirichletPenalty.java

示例12: drot

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
public void drot(DoubleMatrix1D x, DoubleMatrix1D y, double c, double s) {
	x.checkSize(y);
	DoubleMatrix1D tmp = x.copy();
	
	x.assign(F.mult(c));
	x.assign(y,F.plusMult(s));

	y.assign(F.mult(c));
	y.assign(tmp,F.minusMult(s));
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:11,代码来源:SeqBlas.java

示例13: incrementRightB

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
/**
 * @param ri_Y
 * @param openRi
 */
public void incrementRightB(DoubleMatrix1D ri_Y, MatrixWithRange openRi, boolean openOnly) {
    openRi.end++;
    cond.init(openRi.start,'S', Condition.GE,openOnly);
    // add these to openRi
    addFeatures(openRi.mat,endOpen, openRi.end,cond);
    if (ri_Y != null) {
        ri_Y.assign(openRi.mat);
        addFeatures(ri_Y,endExact, openRi.end,cond);
        //if (!openOnly) checkMatrix(ri_Y,openRi);
    }
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:16,代码来源:FeatureStore.java

示例14: decrementLeftB

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
/**
 * @param ri_Y
 * @param openRi
 *  get all features with end boundary LE openRi.end and start boundary = openRi.start
 */
public void decrementLeftB(DoubleMatrix1D ri_Y, MatrixWithRange openRi, boolean endOpen) {
    openRi.start--;
    cond.init(openRi.end,'E', Condition.LE,endOpen);
    addFeatures(openRi.mat,startOpen, openRi.start,cond);
    if (ri_Y != null) {
        ri_Y.assign(openRi.mat);
        addFeatures(ri_Y,startExact, openRi.start, cond);
    }
   // if (!endOpen) checkMatrix(ri_Y,openRi);
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:16,代码来源:FeatureStore.java

示例15: deltaR_LShift

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
/**
 * @param leftB
 * @param rightB
 * @param deltaRi
 * @param openDeltaRi
 * 
 * Get all features with left boundary = leftB, right boundary open with a value <= rightB
 */
public void deltaR_LShift(int leftB, int rightB, DoubleMatrix1D deltaRi, DoubleMatrix1D openDeltaRi) {
    // TODO -- default value here should be set so as not to undo positions that are already enabled in full R.
    // current code will only word for the case of no restrict constraint.
    cond.init(rightB,'E',Condition.LE,true);
    if (openDeltaRi != null) {
        openDeltaRi.assign(0);
        addFeatures(openDeltaRi,startOpen,leftB,cond);
        deltaRi.assign(openDeltaRi);
    } else {
        deltaRi.assign(0);
    }
    addFeatures(deltaRi,startExact,leftB,cond);
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:22,代码来源:FeatureStore.java


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