double EMSCRIPTEN_KEEPALIVE NHCalcCall(double dprice, double dsigma, double driskfreerate, double dtargetprice, double dT_t) { double d1 = NHCalcD1(dprice, dsigma, driskfreerate, dtargetprice, dT_t); double d2 = CalcD2(d1, dsigma, dT_t); double Nd1 = Nd(d1); double Nd2 = Nd(d2); double dResult = dprice*exp(-1 * driskfreerate*dT_t)*Nd1 - dtargetprice*exp(-1 * driskfreerate*dT_t)*Nd2; return dResult; }
double EMSCRIPTEN_KEEPALIVE NHCalcPut(double dprice, double dsigma, double driskfreerate, double dtargetprice, double dT_t) { double d1 = NHCalcD1(dprice, dsigma, driskfreerate, dtargetprice, dT_t); double d2 = CalcD2(d1, dsigma, dT_t); double Nd1 = Nd(((-1)*d1)); double Nd2 = Nd(((-1)*d2)); double dResult = dtargetprice*exp(-1 * driskfreerate*dT_t)*Nd2 - dprice*exp(-1 * driskfreerate*dT_t)*Nd1; return dResult; }
Matrix Timoshenko2d::getNd(int sec, const Vector &v, double L) { double pts[maxNumSections]; double Omegai = Omega[sec]; double mu, x, phi1p, phi2p, phi3, phi1, phi4, phi2; beamInt->getSectionLocations(numSections, L, pts); x = L * pts[sec]; // if (Omegai > 1.0e12) { // mu = 0.0; // phi1 = (L-x)*x/L/2.; // //phi1p = 0.5-x/L; // phi2 = -(L-x)*x/L/2.; // //phi2p = -0.5-x/L; // phi3 = 1.0-x/L; // //phi3p = -1.0/L; // phi4 = x/L; // //phi4p = 1.0/L; // } else { mu = 1./(1.+12.*Omegai); phi1 = mu*x*(L-x)*(L-x-6*Omegai*L) /L/L; //phi1p = mu*(3*x*x-4*L*x*(1-3*Omegai)-L*L*(6*Omegai-1))/L/L; phi2 = mu*x*(L-x)*(6*Omegai*L-x) /L/L; //phi2p = mu*(6*L*(L-2*x)*Omegai-(2*L-3*x)*x) /L/L; phi3 = (L-x)*mu*(L-3*x-12*L*Omegai) /L/L; //phi3p = 2*mu*(3*x+L*(6*Omegai-2)) /L/L; phi4 = x*mu*(3*x-2*L*(1+6*Omegai)) /L/L; //phi4p = -2*mu*(L-3*x+6*L*Omegai) /L/L; // } Matrix Nd(3,3); Nd.Zero(); Nd(0,0) = 1./L; Nd(1,1) = phi3; // w, transverse displacement Nd(1,2) = phi4; // Nd(2,1) = phi1; // theta, section rotation Nd(2,2) = phi2; // return Nd; }