For this project, you'd write a small (< 50 lines) Fortran library, which would perform some matrix operations using the Lapack matrix library ([login to view URL]).
## Deliverables
For this project, you'd write a small (< 50 lines) Fortran library, which would perform some matrix operations using the Lapack matrix library ([login to view URL]). It not necessary to understand much about Lapack, since I've provided an implementation (in a different language -- Ocaml) below. You'd translate these two Ocaml methods into Fortran subroutines.
It's not really necessary to understand much about Ocaml to port these. Just know that the statement "let x = 3 in" assigns the value 3 to variable x. All Lapack operations are double precision, so rather than "scal" (Ocaml), call DSCAL (Fortran).
Note that arguments "pu", "m_avg", "m_var", and "m_normal" are vectors of the same length. "r" is a real valued number. Both methods return vectors with the same length as the other vectors.
* * *
method get_normal_density r m_avg m_var m_normal =
let r_vec = [login to view URL] num_z r in
let r_diff = [login to view URL] r_vec m_avg in
let r_sqdiff = [login to view URL] r_diff r_diff in
scal (-0.5) r_sqdiff;
let r_exp = [login to view URL] r_sqdiff m_var in
let get_exp z = exp r_exp.{z} in
let normal_exp = [login to view URL] num_z get_exp in
[login to view URL] m_normal normal_exp
method expectation pu r m_avg m_var m_normal =
let pr_m_vec = self#get_normal_density
r m_avg m_var m_normal in
let pr_mu_vec = [login to view URL] pr_m_vec pu in
let pr_mu = [login to view URL] pr_mu_vec in
scal (1. /. pr_mu) pr_mu_vec;
pr_mu_vec
* * *
I'm planning to call your Fortran library from my Ocaml program. If you'd be willing to provide a sample Ocaml program that calls your Fortran library (see [login to view URL]), let me know, and we can agree on a higher price or a bonus or something. Otherwise, I'll remove this paragraph from the project description before accepting your bid. The sample program should demonstrate that calling the Fortran code does not block other Ocaml threads from running during its execution. My hope is that each call to the Fortran code will run on a different processor, when multiple processors are available.
Please let me know if you have questions. Thank you.
## Platform
Linux, g77