{"text": "#include \n#include \n\n#include \n\n#include \n#include \n\n// Flag for slope reconstruction type\nenum class Slope { Zero, Reconstructed };\n\n//! \\breif Implements a piecewise cubic Herite interpolation on equidistant meshes.\nclass PCHI {\npublic:\n //! \\brief Construct the slopes frome the data, either usinf dinite-differences or assuming f'(x_j) = 0\n //! \\param[in] t vector of nodes (assumed equidistant and sorted)\n //! \\param[in] y vector of values at nodes t\n //! \\param[in] s Flag to set if you want to reconstruct or set slopes to zero\n PCHI(const Eigen::VectorXd & t, const Eigen::VectorXd & y, Slope s = Slope::Reconstructed)\n : t(t), y(y), c(t.size()) {\n // Sanity check\n n = t.size();\n assert( n == y.size() && \"t and y must have same dimension.\" );\n assert( n >= 3 && \"need at least two nodes.\" );\n h = t(1) - t(0);\n \n switch(s) {\n //// CASE: reconstruction of the slope, assuming f'(x_j) = 0 (O(1))\n case Slope::Zero:\n c = Eigen::VectorXd::Zero(n);\n break;\n //// CASE: reconstruction of the slope using a second order finite difference (O(h^2))\n case Slope::Reconstructed:\n default:\n// c(0) = ( y(1) - y(0) ) / h; // First order\n c(0) = ( -1*y(2) + 4*y(1) - 3*y(0) ) / 2 / h;\n for(int i = 1; i < n-1; ++i) {\n c(i) = ( y(i+1) - y(i-1) ) / 2 / h;\n }\n// c(n-1) = ( y(n-1) - y(n-2) ) / h; // First order\n c(n-1) = ( 3*y(n-1) - 4*y(n-2) + 1*y(n-3) ) / 2 / h;\n break;\n }\n }\n \n //! \\brief Evaluate the intepolant at the nodes x\n //! Input assumed sorted, unique and inside the interval\n //! \\param[in] x vector of points t where to compute s(t)\n //! \\return values of interpolant at x (vector)\n Eigen::VectorXd operator() (Eigen::VectorXd x) const {\n \n Eigen::VectorXd ret(x.size());\n // Stores the current interval index and some temporary variable\n int i_star = 0;\n double tmp,t1,y1,y2,c1,c2,a1,a2,a3;\n for(int j = 0; j < x.size(); ++j) {\n // Find interval and porting of hermloceval Matlab code 3.4.6\n if( t(i_star) < x(j) || i_star == 0) { \n ++i_star;\n t1 = t(i_star-1);\n y1 = y(i_star-1);\n y2 = y(i_star);\n c1 = c(i_star-1);\n c2 = c(i_star);\n a1 = y2 - y1;\n a2 = a1 - h*c1;\n a3 = h*c2 - a1 - a2;\n }\n // Compute s(x(j))\n tmp = ( x(j) - t1 ) / h;\n ret(j) = y1 + ( a1 + ( a2+a3*tmp ) * ( tmp - 1. ) ) * tmp;\n }\n \n return ret;\n }\n \nprivate:\n // Provided nodes and values (t,y) to compute spline, same size Eigen vectors, c contains slopes\n Eigen::VectorXd t, y, c;\n // Difference t(i)-t(i-1) and coefficients of spline (s'(t_j))\n double h;\n // Size of t, y and c.\n int n;\n};\n\n// Interpoland\nauto f = [] (double x) { return 1. / (1. + x*x); };\n// auto f = [] (double x) {return cos(x); };\n\nint main() {\n \n double a = 5; // Interval (-a,a) bounds\n int M = 1000; // Number of points in which to evaluate\n \n // Number of subintervals for each test\n std::vector N = {4,8,16,32,64,128,256,512};\n \n // Precompute values at which evaluate f\n Eigen::VectorXd x = Eigen::VectorXd::LinSpaced(M, -a, a);\n Eigen::VectorXd fx(x.size());\n for(int i = 0; i < x.size(); ++i) {\n fx(i) = f(x(i));\n }\n \n // Store error and rates\n std::vector err, err_zero, rate, rate_zero;\n \n std::cout << \"L^infty-error [reconstruction, zero] (rate / rate)\" << std::endl;\n for(int n : N) {\n // Define subintervals and evaluate f there (find pairs (t,y))\n Eigen::VectorXd t = Eigen::VectorXd::LinSpaced(n, -a, a);\n Eigen::VectorXd y(t.size());\n for(int i = 0; i < t.size(); ++i) {\n y(i) = f(t(i));\n }\n \n // Construct PCHI with zero and reconstructed slopes\n PCHI P(t,y), Pz(t,y,Slope::Zero);\n \n // Compute infinity norm of error\n err.push_back((P(x) - fx).lpNorm());\n err_zero.push_back((Pz(x) - fx).lpNorm());\n \n // Store errors and rates\n std::cout << err.back() << \" \" << err_zero.back() ;\n if( err.size() > 1 ) {\n rate.push_back( log( *(err.end() - 2) / err.back() ) / log(2) );\n rate_zero.push_back( log( *(err_zero.end() - 2) / err_zero.back() ) / log(2) );\n std::cout << \" (\" << rate.back() << \" / \" << rate_zero.back() << \")\";\n }\n std::cout << std::endl;\n \n }\n}\n", "meta": {"hexsha": "3d91a01416eb0b116fdd5267ca9f905ecc3b03d1", "size": 4880, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "Nummerical Methods for CSE/PS9/solutions_ps9/piecewise_hermite_interpolation.cpp", "max_stars_repo_name": "valentinjacot/backupETHZ", "max_stars_repo_head_hexsha": "36605c4f532eb65efb4a391ed0f17a07102f7d5b", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2019-12-25T10:21:30.000Z", "max_stars_repo_stars_event_max_datetime": "2019-12-25T10:21:30.000Z", "max_issues_repo_path": "Nummerical Methods for CSE/PS9/solutions_ps9/piecewise_hermite_interpolation.cpp", "max_issues_repo_name": "valentinjacot/backupETHZ", "max_issues_repo_head_hexsha": "36605c4f532eb65efb4a391ed0f17a07102f7d5b", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Nummerical Methods for CSE/PS9/solutions_ps9/piecewise_hermite_interpolation.cpp", "max_forks_repo_name": "valentinjacot/backupETHZ", "max_forks_repo_head_hexsha": "36605c4f532eb65efb4a391ed0f17a07102f7d5b", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 36.1481481481, "max_line_length": 107, "alphanum_fraction": 0.4967213115, "num_tokens": 1435, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9161096090086368, "lm_q2_score": 0.9273632926354616, "lm_q1q2_score": 0.8495664234252347}} {"text": "#include \n\n#include \n\nEigen::MatrixXd Vandermonde(const Eigen::VectorXd &x, int n) {\n int m = x.size();\n\tEigen::MatrixXd V(m, n);\n\n\tV.col(0) = Eigen::VectorXd::Ones(m);\n\n for(int i = 1; i < n; i++) {\n V.col(i) = V.col(i - 1).cwiseProduct(x);\n }\n\n return V;\n}\n\nEigen::VectorXd r(const Eigen::VectorXd &x) {\n\treturn (1.0 / (1.0 + 25.0 * x.array() * x.array())).matrix();\n}\n\nint main() {\n\tint n = 11;\t\t\t\t// Number of polynomial coefficients\n\tint m;\t\t\t\t\t// Number of samples\n\tEigen::MatrixXd V;\t\t// Vandermonde matrix\n\tEigen::VectorXd x;\t\t// Samples in [-1, 1]\n\tEigen::VectorXd y;\t\t// r(x)\n\tEigen::VectorXd a(n);\t// Polynomial coefficients\n\n\tEigen::IOFormat PythonFmt(Eigen::StreamPrecision, Eigen::DontAlignCols, \", \", \";\\n\", \"[\", \"]\", \"[\", \"]\");\n\n\tstd::cout << \"Polynomial coefficients obtained by...\" << std::endl;\n\n\t// Compute overfitted polynomial coefficients\n\tm = n;\n\tx.setLinSpaced(m, -1.0, 1.0);\n y = r(x);\n V = Vandermonde(x, n);\n\ta = V.fullPivLu().solve(y);\n\n\tstd::cout << \"...overfitting:\" << std::endl;\n\tstd::cout << a.transpose().format(PythonFmt) << std::endl;\n\n\t// Compute least squares polynomial coefficients\n\tm = 3 * n;\n\tx.setLinSpaced(m, -1.0, 1.0);\n\n y = r(x);\n V = Vandermonde(x, n);\n // no pivoting required gaussian elimination remains stable since V^TV is s.p.d\n a = (V.transpose() * V).llt().solve(V.transpose() * y);\n\n\tstd::cout << \"...least squares:\" << std::endl;\n\tstd::cout << a.transpose().format(PythonFmt) << std::endl;\n\n\treturn 0;\n}\n", "meta": {"hexsha": "d978d605940203a866cb2f95127bacf82b660dcb", "size": 1499, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "exercise_2/least_squares.cpp", "max_stars_repo_name": "azurite/numCSE18-code", "max_stars_repo_head_hexsha": "f7104305375954a0528d366f8460bf8033d20f0a", "max_stars_repo_licenses": ["MIT"], "max_stars_count": 1.0, "max_stars_repo_stars_event_min_datetime": "2019-01-13T19:08:32.000Z", "max_stars_repo_stars_event_max_datetime": "2019-01-13T19:08:32.000Z", "max_issues_repo_path": "exercise_2/least_squares.cpp", "max_issues_repo_name": "azurite/numCSE18-code", "max_issues_repo_head_hexsha": "f7104305375954a0528d366f8460bf8033d20f0a", "max_issues_repo_licenses": ["MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "exercise_2/least_squares.cpp", "max_forks_repo_name": "azurite/numCSE18-code", "max_forks_repo_head_hexsha": "f7104305375954a0528d366f8460bf8033d20f0a", "max_forks_repo_licenses": ["MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 25.8448275862, "max_line_length": 106, "alphanum_fraction": 0.6090727151, "num_tokens": 478, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9399133447766225, "lm_q2_score": 0.8991213826762113, "lm_q1q2_score": 0.8450961861513794}} {"text": "#include \n#include \"Log.h\"\n//using namespace std;\n#include \n// Eigen libraries\n#include \n// Algebraic operations on dense matrices (inverse, eigenvalues, etc.)\n#include \n\n#define MATRIX_SIZE 50\n\n/****************************\n* Basic usage of Eigen matrix\n****************************/\n\nint main( int argc, char** argv )\n{\n //Set the log first \n za::my_logger::logger_type log = za::my_logger::get();\n za::Log logManager; \n logManager.set_log_file(\"./log/logEigenMatix.log\"); \n BOOST_LOG_SEV(log, za::report) <<\"Basic Eigen lib Matrix demo\\n\";\n \n //All vectors and matrices in Eigen are Eigen::Matrix, which is a template class. \n //Its first three parameters are: data type, row, column\n // Declare a 2*3 float matrix\n Eigen::Matrix matrix_23;\n\n // At the same time, Eigen provides many built-in types through typedef, \n // but the bottom layer is still Eigen::Matrix\n // For example, Vector3d is essentially Eigen::Matrix, \n // which is a three-dimensional vector\n Eigen::Vector3d v_3d;\n\t// Same as \n Eigen::Matrix vd_3d;\n\n // Matrix3d is essentially Eigen::Matrix\n Eigen::Matrix3d matrix_33 = Eigen::Matrix3d::Zero(); //Initialized to zero\n // If you are not sure about the size of the matrix\n // you can use a dynamically sized matrix\n Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > matrix_dynamic;\n // Simple format for unknown size\n Eigen::MatrixXd matrix_x;\n // Check other type of dynamic matrix\n\n // The following is the operation of the Eigen array\n // Input data (initialization) \n matrix_23 << 1, 2, 3, 4, 5, 6;\n BOOST_LOG_SEV(log, za::report) << \"2 by 3 matrix initialization, row major:\\n\";\n // Output\n BOOST_LOG_SEV(log, za::report) << matrix_23 << \"\\n\";\n\n // Use () to access the elements in the matrix\n for (int i=0; i result_wrong_type = matrix_23 * v_3d;\n // should be explicitly converted\n Eigen::Matrix result = matrix_23.cast() * v_3d;\n BOOST_LOG_SEV(log, za::report) << result << \"\\n\";\n\n Eigen::Matrix result2 = matrix_23 * vd_3d;\n BOOST_LOG_SEV(log, za::report) << result2 << \"\\n\";\n\n // Similarly you can't make a mistake about the dimensions of the matrix\n // Try to cancel the comment below and see what error Eigen will report\n // Eigen::Matrix result_wrong_dimension = matrix_23.cast() * v_3d;\n\n // some matrix operations\n // The four arithmetic operations will not be demonstrated, just use +-*/.。\n matrix_33 = Eigen::Matrix3d::Random(); // Random number matrix\n BOOST_LOG_SEV(log, za::report) << matrix_33 << \"\\n\" << \"\\n\";\n\n BOOST_LOG_SEV(log, za::report) << matrix_33.transpose() << \"\\n\"; // Transpose\n BOOST_LOG_SEV(log, za::report) << matrix_33.sum() << \"\\n\"; // Sum\n BOOST_LOG_SEV(log, za::report) << matrix_33.trace() << \"\\n\"; // Trace\n BOOST_LOG_SEV(log, za::report) << 10*matrix_33 << \"\\n\"; // Multiplication\n BOOST_LOG_SEV(log, za::report) << matrix_33.inverse() << \"\\n\"; // Inverse\n BOOST_LOG_SEV(log, za::report) << matrix_33.determinant() << \"\\n\"; // Determinant\n\n // Eigenvalues\n // Real symmetric matrix can ensure the success of diagonalization\n Eigen::SelfAdjointEigenSolver eigen_solver ( matrix_33.transpose()*matrix_33 );\n BOOST_LOG_SEV(log, za::report) << \"Eigen values = \\n\" << eigen_solver.eigenvalues() << \"\\n\";\n BOOST_LOG_SEV(log, za::report) << \"Eigen vectors = \\n\" << eigen_solver.eigenvectors() << \"\\n\";\n\n // Solving equations\n // We solve the equation matrix_NN * x = v_Nd\n // The size of N is defined in the previous macro, it is generated by a random number\n // Direct inversion is naturally the most straightforward, but the amount of inversion calculations is large\n\n Eigen::Matrix< double, MATRIX_SIZE, MATRIX_SIZE > matrix_NN;\n matrix_NN = Eigen::MatrixXd::Random( MATRIX_SIZE, MATRIX_SIZE );\n Eigen::Matrix< double, MATRIX_SIZE, 1> v_Nd;\n v_Nd = Eigen::MatrixXd::Random( MATRIX_SIZE,1 );\n\n clock_t time_stt = clock(); // timer\n // take inverse\n Eigen::Matrix x = matrix_NN.inverse()*v_Nd;\n BOOST_LOG_SEV(log, za::report) <<\"time use in normal inverse is \" << 1000* (clock() - time_stt)/(double)CLOCKS_PER_SEC << \"ms\"<< \"\\n\";\n \n\t// qr decomposition\n time_stt = clock();\n x = matrix_NN.colPivHouseholderQr().solve(v_Nd);\n BOOST_LOG_SEV(log, za::report) <<\"time use in Qr decomposition is \" <<1000* (clock() - time_stt)/(double)CLOCKS_PER_SEC <<\"ms\" << \"\\n\";\n\n return 0;\n}\n", "meta": {"hexsha": "381abc8f2833c35dcaef3928f1183bab799bc6c5", "size": 5138, "ext": "cpp", "lang": "C++", "max_stars_repo_path": "src/eigenMatrix.cpp", "max_stars_repo_name": "zoumson/Eigen", "max_stars_repo_head_hexsha": "9975ba3a123708a9b4cbe5131e818f19edd9e378", "max_stars_repo_licenses": ["Unlicense", "MIT"], "max_stars_count": null, "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/eigenMatrix.cpp", "max_issues_repo_name": "zoumson/Eigen", "max_issues_repo_head_hexsha": "9975ba3a123708a9b4cbe5131e818f19edd9e378", "max_issues_repo_licenses": ["Unlicense", "MIT"], "max_issues_count": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/eigenMatrix.cpp", "max_forks_repo_name": "zoumson/Eigen", "max_forks_repo_head_hexsha": "9975ba3a123708a9b4cbe5131e818f19edd9e378", "max_forks_repo_licenses": ["Unlicense", "MIT"], "max_forks_count": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null, "avg_line_length": 44.6782608696, "max_line_length": 141, "alphanum_fraction": 0.6457765668, "num_tokens": 1461, "lm_name": "Qwen/Qwen-72B", "lm_label": "1. YES\n2. YES", "lm_q1_score": 0.9425067195846919, "lm_q2_score": 0.896251377983158, "lm_q1q2_score": 0.8447229461861661}} {"text": "/* ------------------------------------------------------------\n * @file: pseudoinversa.cpp\n * @dependencias: armadillo, matplotlibcpp\n * @version 0.1\n * ------------------------------------------------------------*/\n\n// [1] $ g++ pseudoinversa.cpp -o psi.out -std=c++11\n// [2] $ ./psi.out\n// Nota: Asegurarse de tener armadillo bien instalado.\n\n#include \n\nusing namespace std;\nusing namespace arma;\n\n\n/**\n * @brief Calcula la aproximación a la solución de un sistema de ecuaciones por \n * el método de la pseudoinversa.\n * @param A Matriz de coeficientes.\n * @param b Vector de términos independientes.\n * @param tol Tolerancia de la aproximación.\n * @param max_itr Iteraciones máximas.\n */\nvoid pseudoinversa(mat A, vec b, double tol, int max_itr=15){\n int n = A.n_rows;\n int m = A.n_cols;\n double alpha = eig_sym(A*A.t()).max();\n\n mat I(n,m);\n I.eye();\n mat x = (1/alpha)*A.t();\n\n double error = tol;\n int k = 0;\n\n while (k < max_itr){\n x = x*(2*I-A*x);\n error = norm((A*x*A)-A);\n\n if (error < tol)\n break;\n k++;\n }\n mat x_p = x*b;\n\n // Mostrar los resultados\n x_p.print(\"x_p: \\n\");\n cout<<\"Error: \"<< norm(A*x_p-b)<\r\n#include \r\n\r\n\r\nint main()\r\n{\r\n\t// Group A =Exact Solutions of One-Factor Plain Options==================================================\r\n\t// 1 part a) Implement the above formula for call and put option pricing using data sets\r\n\t// Batch 1 to Batch 4. Check your answers.\r\n\r\n\t// Batch 1\r\n\tTime T1 = (Time) 0.25;\r\n\tStrike_Price K1 = (Strike_Price)65;\r\n\tVolatility sig1 = (Volatility) 0.30;\r\n\trate r1 = (rate) 0.08;\r\n\tcost_of_carry b1 = (cost_of_carry) 0.08;\r\n\tcurr_stock_price S1 = (curr_stock_price) 60.0;\r\n\r\n\t// Create option and set parameters\r\n\tEuropeanOption option1;\r\n\toption1.SetOption(T1, K1, sig1, r1, b1, S1);\r\n\r\n\tcout << \"Batch 1 Call price: \" << option1.CallPriceEuro() << endl;\r\n\tcout << \"Batch 1 Put price: \" << option1.PutPriceEuro() << endl;\r\n\r\n\t// Batch 2\r\n\tTime T2 = (Time) 1.0;\r\n\tStrike_Price K2 = (Strike_Price) 100.0;\r\n\tVolatility sig2 = (Volatility) 0.2;\r\n\trate r2 = (rate) 0.00;\r\n\tcost_of_carry b2 = (cost_of_carry) 0.00;\r\n\tcurr_stock_price S2 = (curr_stock_price) 100.0;\r\n\r\n\t// Create option and set parameters\r\n\tEuropeanOption option2;\r\n\toption2.SetOption(T2, K2, sig2, r2, b2, S2);\r\n\r\n\tcout << \"Batch 2 Call price: \" << option2.CallPriceEuro() << endl;\r\n\tcout << \"Batch 2 Put price: \" << option2.PutPriceEuro() << endl;\r\n\r\n\t// Batch 3\r\n\tTime T3 = (Time) 1.0;\r\n\tStrike_Price K3 = (Strike_Price) 10.0;\r\n\tVolatility sig3 = (Volatility) 0.50;\r\n\trate r3 = (rate) 0.12;\r\n\tcost_of_carry b3 = (cost_of_carry) 0.12;\r\n\tcurr_stock_price S3 = (curr_stock_price) 5.0;\r\n\r\n\t// Create option and set parameters\r\n\tEuropeanOption option3;\r\n\toption3.SetOption(T3, K3, sig3, r3, b3, S3);\r\n\r\n\tcout << \"Batch 3 Call price: \" << option3.CallPriceEuro() << endl;\r\n\tcout << \"Batch 3 Put price: \" << option3.PutPriceEuro() << endl;\r\n\r\n\t// Batch 4\r\n\tTime T4 = (Time) 30.0;\r\n\tStrike_Price K4 = (Strike_Price) 100.0;\r\n\tVolatility sig4 = (Volatility) 0.30;\r\n\trate r4 = (rate) 0.08;\r\n\tcost_of_carry b4 = (cost_of_carry) 0.08;\r\n\tcurr_stock_price S4 = (curr_stock_price) 100.0;\r\n\r\n\t// Create option and set parameters\r\n\tEuropeanOption option4;\r\n\toption4.SetOption(T4, K4, sig4, r4, b4, S4);\r\n\r\n\tcout << \"Batch 4 Call price: \" << option4.CallPriceEuro() << endl;\r\n\tcout << \"Batch 4 Put price: \" << option4.PutPriceEuro() << endl;\r\n\r\n\tcout << endl;\r\n\t//================================================================================================================================================================================\r\n\t\t// 1 b) Apply the put-call parity relationship lto compute the put prices given the call prices\r\n\t\t// We use our CalltoPutParity function.\r\n\r\n\tcout << \"Using Parity: \" << endl;\r\n\tcout << \"Batch 1 Put Price: \" << option1.CalltoPutParity() << endl;\r\n\tcout << \"Batch 2 Put Price: \" << option2.CalltoPutParity() << endl;\r\n\tcout << \"Batch 3 Put Price: \" << option3.CalltoPutParity() << endl;\r\n\tcout << \"Batch 4 Put Price: \" << option4.CalltoPutParity() << endl;\r\n\r\n\tcout << endl;\r\n\r\n\t// Now we check if the batches satisfy put-call parity.\r\n\tcout << \"Batch 1 satisfies parity: \" << (option1.ParityChecker() ? \"True.\" : \"False.\") << endl;\r\n\tcout << \"Batch 2 satisfies parity: \" << (option2.ParityChecker() ? \"True.\" : \"False.\") << endl;\r\n\tcout << \"Batch 3 satisfies parity: \" << (option3.ParityChecker() ? \"True.\" : \"False.\") << endl;\r\n\tcout << \"Batch 4 satisfies parity: \" << (option4.ParityChecker() ? \"True.\" : \"False.\") << endl;\r\n\t//================================================================================================================================================================================\t\r\n\t\t// 1 c) We compute the option prices for a monotonically increasing ranges of values for S, the current stock price.\r\n\t\t// Let S = 10, 11, 12, ... 50. We use our MeshArray.\r\n\tcurr_stock_price S_start = (curr_stock_price) 10.0;\r\n\tcurr_stock_price S_end = (curr_stock_price) 50.0;\r\n\tcurr_stock_price S_interval = (curr_stock_price) 1.0;\r\n\r\n\t// Compute the Call prices and Put prices\r\n\tvector S_array = MeshArray(S_start, S_end, S_interval);\r\n\tvector S_CallPrices = option1.CallPriceEuro(S_array);\r\n\tvector S_PutPrices = option1.PutPriceEuro(S_array);\r\n\r\n\tcout << endl;\r\n\tcout << \"S - Value, Call Price, Put Price\" << endl;\r\n\tPrintArray(S_array, S_CallPrices, S_PutPrices);\r\n\r\n\tcout << endl;\r\n\r\n\t// reset the option\r\n\toption1.SetOption(T1, K1, sig1, r1, b1, S1);\r\n\t//================================================================================================================================================================================\r\n\t\t// 1 d) We create a matrix pricer to determine prices as we vary two parameters. We use expiry time and volatility.\r\n\r\n\t\t// Create Vector of T-values. This is where we change our option parameter.\r\n\tTime T_start = (Time) 0.25;\r\n\tTime T_end = (Time) 5.0;\r\n\tTime T_interval = (Time) 0.25;\r\n\tvector