Ejemplo n.º 1
0
void MarkovExpectation::compute(FitContext *fc, const char *what, const char *how)
{
	if (fc) {
		for (auto c1 : components) {
			c1->compute(fc, what, how);
		}
	}

	omxRecompute(initial, fc);
	if (initialV != omxGetMatrixVersion(initial)) {
		omxCopyMatrix(scaledInitial, initial);
		EigenVectorAdaptor Ei(scaledInitial);
		if (scale == SCALE_SOFTMAX) Ei.derived() = Ei.array().exp();
		if (scale != SCALE_NONE) {
			Ei /= Ei.sum();
		}
		if (verbose >= 2) mxPrintMat("initial", Ei);
		initialV = omxGetMatrixVersion(initial);
	}

	if (transition) {
		omxRecompute(transition, fc);
		if (transitionV != omxGetMatrixVersion(transition)) {
			omxCopyMatrix(scaledTransition, transition);
			EigenArrayAdaptor Et(scaledTransition);
			if (scale == SCALE_SOFTMAX) Et.derived() = Et.array().exp();
			if (scale != SCALE_NONE) {
				Eigen::ArrayXd v = Et.colwise().sum();
				Et.rowwise() /= v.transpose();
			}
			if (verbose >= 2) mxPrintMat("transition", Et);
			transitionV = omxGetMatrixVersion(transition);
		}
	}
}
Ejemplo n.º 2
0
void channelns() {
  double nx = 41;
  double ny = 41;
  double nt = 10;
  double nit = 50;
  double c  = 1;
  double dx = 2/(nx-1);
  double dy = 2/(ny-1);
  
  double rho = 1;
  double nu =.1;
  double F = 1;
  double dt = .01;
  
  std::string dir = "step11/";
  
  Eigen::ArrayXd x; // Array containing our x values
  x.setLinSpaced(nx,0,2); // Array is linearly spaced values from 0 to 2
  
  Eigen::ArrayXd y; // Array containing our x values
  y.setLinSpaced(ny,0,2);
  
  Eigen::ArrayXXd X;
  Eigen::ArrayXXd Y;
  
  X = x.transpose().replicate(nx,1); // Need to transpose this because the type we declared, ArrayXd, is row-major (and we need column-major for a proper meshgrid)
  Y = y.replicate(1,ny);
  
  Eigen::ArrayXXd u;
  u.setZero(ny,nx);
  Eigen::ArrayXXd un;
  un.setZero(ny,nx);
  Eigen::ArrayXXd v;
  v.setZero(ny,nx);
  Eigen::ArrayXXd vn;
  vn.setZero(ny,nx);
  Eigen::ArrayXXd b; 
  b.setZero(ny,nx);
  Eigen::ArrayXXd p;
  p.setZero(ny,nx);
  Eigen::ArrayXXd pn;
  pn.setZero(ny,nx);
  
  
}