/* * main function in order to obtain the * correct stress using Mohr-Coulomb criteria */ void mohrcoulomb (double c, double phi, double psi, double nu, double ymod, double eps[4], double *stress, double sigma[4]) { double elso[5]; double fnew; for (i = 1; i <= 4; i++) { elso[i] = 0; } for (i = 1; i <= 4; i++) { cs[i] = stress[i + 3] + sigma[i]; } invar (); fnew = mocouf (c, phi); if (fnew > 0) { mocopl (phi, psi, nu, ymod); elso[1] = pl[1][1] * eps[1] + pl[1][2] * eps[2] + pl[1][3] * eps[3]; elso[2] = pl[2][1] * eps[1] + pl[2][2] * eps[2] + pl[2][3] * eps[3]; elso[3] = pl[3][1] * eps[1] + pl[3][2] * eps[2] + pl[3][3] * eps[3]; elso[4] = pl[4][1] * eps[1] + pl[4][2] * eps[2] + pl[4][3] * eps[3]; } for (i = 1; i <= 4; i++) { stress[i + 3] = stress[i + 3] + sigma[i] - elso[i]; } }
int main(const int argc, const char** argv) { if (argc != 2) LFATAL("USAGE: %s <image.pgm>", argv[0]); // let's start by trying out a single model: it starts with our // initial conditions and we give it a steady input of 255: SurpriseModelSP m(UPDFAC, INIVAL, VARIANCE); // the model SurpriseModelSP s(UPDFAC, 255.0f, VARIANCE); // the sample for (int i = 0; i < NITER; i ++) LINFO("iter = %d, mean = %f, stdev = %f, surprise = %f", i, m.getMean(), sqrt(m.getVar()), m.surprise(s)); // get the input feature map: Image<byte> input = Raster::ReadGray(argv[1]); // convert to double: Image<double> in(input); // create sample variances: Image<double> invar(input.getDims(), NO_INIT); invar.clear(VARIANCE); // create SurpriseImage from our samples and their variances: SurpriseImage<SurpriseModelSP> sample(UPDFAC, in, invar); // create an ImageCache to accumulate our results: ImageCacheMinMax<float> cache; // create a surprise map: SurpriseMap<SurpriseModelSP> smap; smap.init(QLEN, UPDFAC, NUPDFAC, INIVAL, VARIANCE, NEIGHSIGMA, LOCSIGMA); // let's do it! for (int i = 0; i < NITER; i ++) { // get the surprise: Image<float> surp = smap.surprise(sample); float mi, ma; getMinMax(surp, mi, ma); LINFO("Done %d/%d: [%f .. %f]", i+1, NITER, mi, ma); // cache it: cache.push_back(surp); } // ok, let's save the results. First find the global max: Image<float> imax = cache.getMax(); float mi, ma; getMinMax(imax, mi, ma); LINFO("Global max is %f", ma); for (int i = 0; i < NITER; i ++) { Image<byte> sav(cache.pop_front() * 255.0f / ma); Raster::WriteGray(sav, sformat("SURP%03d%s", i, argv[1])); } return 0; }
struct syntax_node * input_stm(){ struct syntax_node * t; t = (struct syntax_node*)malloc(sizeof(struct syntax_node)); chushihua_t(t); t->child[0] = rev_read(); t->child[1] = zuokuohao(); t->child[2] = invar(); t->child[3] = youkuohao(); strcpy(t->kind_name, "InputStm"); return t; }