update mise en page boucle
This commit is contained in:
parent
118b3c47df
commit
522adc89e6
186
Calcul.ipynb
186
Calcul.ipynb
@ -31,7 +31,10 @@
|
||||
" (* 10. Matrice intermédiaire pour supprimer i j et ajouter i~ et j~ *)\n",
|
||||
" (* 11. Matrice intérmédiaire où les orbitales i et j ont été supprimées et remplacées par des 0*)\n",
|
||||
" \n",
|
||||
"(* IV : Boucle de localisation des OMs *) \n",
|
||||
"(* IV : Localisation des OMs *)\n",
|
||||
" (* 1. Boucle de localisation des OMs *)\n",
|
||||
" (* 2. Fonction de localisation *)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"(* V : Fonctions pour la séparation et le rassemblement des matrices *)\n",
|
||||
" (* 1. Fonction de création d'une list d'entier à partir d'un vecteur de float*)\n",
|
||||
@ -521,41 +524,23 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"(* IV : Boucle de localisation des OMs *)\n",
|
||||
"(* IV : Localisation des OMs *)\n",
|
||||
"\n",
|
||||
"(* Calcul de la nouvelle matrice des coefficient après n rotation d'orbitales *)\n",
|
||||
"let rec localisation m_C methode epsilon n prev_critere_D cc=\n",
|
||||
"\n",
|
||||
" Printf.printf \"%i\\n%!\" n;\n",
|
||||
"(* 1. Boucle de calcul de la nouvelle matrice des coefficient après n rotation d'orbitales *)\n",
|
||||
"let rec localisation m_C methode epsilon n prev_critere_D prev_m_alpha cc max_D=\n",
|
||||
"\n",
|
||||
" (*Printf.printf \"%i\\n%!\" n;*)\n",
|
||||
" (*Printf.printf \"%f\\n%!\" epsilon;*)\n",
|
||||
" (*Util.debug_matrix \"m_C\" m_C;*)\n",
|
||||
" (*Util.debug_matrix \"new_alpha_m\" prev_m_alpha;*)\n",
|
||||
"\n",
|
||||
"if n == 0 \n",
|
||||
" then m_C\n",
|
||||
" else\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" (* Fonction de calcul de la nouvelle matrice de coef après rotation d'un angle alpha *)\n",
|
||||
" let new_m_C m_C methode =\n",
|
||||
" \n",
|
||||
" (* Fonction de pattern matching en fonction de la méthode *)\n",
|
||||
" let alphad = m_alpha_d methode m_C \n",
|
||||
" in\n",
|
||||
" \n",
|
||||
" (* D critère à maximiser *)\n",
|
||||
" let critere_D = alphad.d \n",
|
||||
" in\n",
|
||||
" \n",
|
||||
" Printf.printf \"%f\\n%!\" critere_D;\n",
|
||||
" \n",
|
||||
" (* Matrice des alphas *)\n",
|
||||
" let m_alpha = alphad.m_alpha\n",
|
||||
" in\n",
|
||||
" let norme_alpha = norme m_alpha\n",
|
||||
" in\n",
|
||||
" \n",
|
||||
" Printf.printf \"%f\\n%!\" norme_alpha;\n",
|
||||
" \n",
|
||||
" (*Util.debug_matrix \"m_alpha\" m_alpha;*)\n",
|
||||
" let new_m_C m_C methode m_alpha epsilon =\n",
|
||||
"\n",
|
||||
" (* alphaij contient le alpha max ainsi que ses indices i et j *)\n",
|
||||
" let n_rec_alpha = 10 (* Nombre ditération max pour réduire les valeurs de alpha *)\n",
|
||||
@ -567,72 +552,127 @@
|
||||
" let alpha = (alphaij.alpha_max) *. epsilon \n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" (*Printf.printf \"%f\\n%!\" alpha;*)\n",
|
||||
" \n",
|
||||
" (*Printf.printf \"%f\\n%!\" alpha;*)\n",
|
||||
"\n",
|
||||
" (* Indice i et j du alpha max après calcul *)\n",
|
||||
" let indice_i = alphaij.indice_ii \n",
|
||||
" in\n",
|
||||
" let indice_j = alphaij.indice_jj \n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" (*Printf.printf \"%i %i\\n%!\" indice_i indice_j;*)\n",
|
||||
" \n",
|
||||
" (*Printf.printf \"%i %i\\n%!\" indice_i indice_j;*)\n",
|
||||
"\n",
|
||||
" (* Matrice de rotation *)\n",
|
||||
" let m_R = f_R alpha \n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" (*Util.debug_matrix \"m_R\" m_R;*)\n",
|
||||
" (*Util.debug_matrix \"m_R\" m_R;*)\n",
|
||||
"\n",
|
||||
" (* Matrice qui va subir la rotation *)\n",
|
||||
" let m_Ksi = f_Ksi indice_i indice_j m_C \n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" (*Util.debug_matrix \"m_Ksi\" m_Ksi;*)\n",
|
||||
" (*Util.debug_matrix \"m_Ksi\" m_Ksi;*)\n",
|
||||
"\n",
|
||||
" (* Matrice ayant subit la rotation *)\n",
|
||||
" let m_Ksi_tilde = f_Ksi_tilde m_R m_Ksi m_C \n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" (*Util.debug_matrix \"m_Ksi_tilde\" m_Ksi_tilde;*)\n",
|
||||
" (*Util.debug_matrix \"m_Ksi_tilde\" m_Ksi_tilde;*)\n",
|
||||
"\n",
|
||||
" (* Matrice pour supprimerles coef des orbitales i et j dans la matrice des coef *)\n",
|
||||
" let m_Psi = f_k m_Ksi indice_i indice_j m_C\n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" (*Util.debug_matrix \"m_Psi\" m_Psi;*)\n",
|
||||
" (*Util.debug_matrix \"m_Psi\" m_Psi;*)\n",
|
||||
"\n",
|
||||
" (* Matrice pour ajouter les coef des orbitales i~ et j~ dans la matrice des coef *)\n",
|
||||
" let m_Psi_tilde = f_k m_Ksi_tilde indice_i indice_j m_C \n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" (*Util.debug_matrix \"m_Psi_tilde\" m_Psi_tilde;*)\n",
|
||||
" (*Util.debug_matrix \"m_Psi_tilde\" m_Psi_tilde;*)\n",
|
||||
"\n",
|
||||
" (* Matrice avec les coef des orbitales i et j remplacés par 0 *)\n",
|
||||
" let m_interm = f_interm m_C m_Psi \n",
|
||||
" in\n",
|
||||
" \n",
|
||||
" (*Util.debug_matrix \"m_interm\" m_interm;*)\n",
|
||||
" \n",
|
||||
" (* Matrice après rotation *)\n",
|
||||
" ( Mat.add m_Psi_tilde m_interm, critere_D, norme_alpha)\n",
|
||||
" in\n",
|
||||
" let m_new_m_C , critere_D, norme_alpha = new_m_C m_C methode \n",
|
||||
" in\n",
|
||||
" let diff = prev_critere_D -. critere_D \n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" (*Util.debug_matrix \"m_interm\" m_interm;*)\n",
|
||||
"\n",
|
||||
" (* Matrice après rotation *)\n",
|
||||
" (Mat.add m_Psi_tilde m_interm, alpha)\n",
|
||||
"\n",
|
||||
" in\n",
|
||||
" (* Extraction de la nouvelle matrice des coef et du alpha_max *)\n",
|
||||
" let m_new_m_C, alpha_max = new_m_C m_C methode prev_m_alpha epsilon\n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" (* Fonction de pattern matching en fonction de la méthode *)\n",
|
||||
" let alphad = m_alpha_d methode m_new_m_C\n",
|
||||
" in\n",
|
||||
" \n",
|
||||
" (* Matrice des alphas *)\n",
|
||||
" let m_alpha = alphad.m_alpha\n",
|
||||
" in\n",
|
||||
" \n",
|
||||
" (* Critères possibles de localisation -> norme_alpha, moyenne_alpha, alpha, diff *)\n",
|
||||
" \n",
|
||||
" (* Norme de m_alpha, moyenne et max *)\n",
|
||||
" let norme_alpha = norme m_alpha\n",
|
||||
" in\n",
|
||||
" let moyenne_alpha = norme_alpha /. (float_of_int((Mat.dim1 m_C)* (Mat.dim2 m_C)))\n",
|
||||
" in\n",
|
||||
" let alpha = alpha_max /. epsilon\n",
|
||||
" in\n",
|
||||
" \n",
|
||||
" (* D critère à maximiser *)\n",
|
||||
" let critere_D = alphad.d \n",
|
||||
" in\n",
|
||||
" let diff = max_D -. critere_D \n",
|
||||
" in\n",
|
||||
" \n",
|
||||
" (*Printf.printf \"%f\\n%!\" diff;*)\n",
|
||||
" Printf.printf \"%i %f %f %f %f %f\\n%!\" n max_D critere_D alpha norme_alpha moyenne_alpha;\n",
|
||||
" \n",
|
||||
" (* Stabilisation de la convergence *)\n",
|
||||
"\n",
|
||||
" let max_D =\n",
|
||||
" if diff > 0.\n",
|
||||
" then max_D\n",
|
||||
" else critere_D\n",
|
||||
" in\n",
|
||||
" \n",
|
||||
" if diff > 0. && epsilon > 0.001\n",
|
||||
" then localisation m_C methode (epsilon /. 1000.) (n-1) critere_D prev_m_alpha cc max_D\n",
|
||||
" else let epsilon = 1.\n",
|
||||
" in\n",
|
||||
" \n",
|
||||
" (*Util.debug_matrix \"new_alpha_m\" m_alpha;*)\n",
|
||||
" (*Util.debug_matrix \"m_new_m_C\" m_new_m_C;*)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
" (* Critère de conv pour sortir *)\n",
|
||||
" if diff**2. < cc**2.\n",
|
||||
" then m_new_m_C\n",
|
||||
" else localisation m_new_m_C methode epsilon (n-1) critere_D m_alpha cc max_D;;\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"(* 2. Fonction de localisation *)\n",
|
||||
"let localise localisation m_C methode epsilon n cc=\n",
|
||||
" let alphad = m_alpha_d methode m_C \n",
|
||||
" in\n",
|
||||
" let prev_m_alpha = alphad.m_alpha\n",
|
||||
" in \n",
|
||||
" let prev_critere_D = 0.\n",
|
||||
" in\n",
|
||||
" let max_D = 0.\n",
|
||||
"in\n",
|
||||
"\n",
|
||||
"(*Util.debug_matrix \"new_alpha_m\" (f_alpha m_C);*)\n",
|
||||
"(*Util.debug_matrix \"m_new_m_C\" m_new_m_C;*)\n",
|
||||
"\n",
|
||||
"if diff**2. < cc**2.\n",
|
||||
" then m_new_m_C\n",
|
||||
" else\n",
|
||||
"localisation m_new_m_C methode epsilon (n-1) critere_D cc;;\n",
|
||||
"\n",
|
||||
"(* Calcul *)\n",
|
||||
"(* Fonction / Matrice des coef / Méthode(\"Boys\" ou \"ER\") / Pas(<=1.) \n",
|
||||
"/ Nombre d'itérations max / 0. (valeur de D pour initier la boucle) / critère de convergence sur D*)\n"
|
||||
"localisation m_C methode epsilon n prev_critere_D prev_m_alpha cc max_D;;"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -700,26 +740,28 @@
|
||||
"source": [
|
||||
"(* VI : Calcul et assemblage des OMs occupées/virtuels *)\n",
|
||||
"\n",
|
||||
"(* Fonction / Matrice des coef / Méthode(\"Boys\" ou \"ER\") / Pas(<=1.) \n",
|
||||
"/ Nombre d'itérations max / 0. (valeur de D pour initier la boucle) / critère de convergence sur D*)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"(*let new_m_boys = localisation m_C \"boys\" 1. 100 0. 10e-7;;\n",
|
||||
"let new_m_er = localisation m_C \"ER\" 1. 100 0. 10e-7;;\n",
|
||||
"(* Calcul : \n",
|
||||
"localise localisation / Matrice des coef / \"Methode\" (boys/er) / nb itération max / critère de convergence \n",
|
||||
"*)\n",
|
||||
"\n",
|
||||
"let loc_m_occ_boys = localisation m_occ \"boys\" 1. 100 0. 10e-7;;\n",
|
||||
"let loc_m_vir_boys = localisation m_vir \"boys\" 1. 100 0. 10e-7;;\n",
|
||||
"let m_assemble_boys = assemble loc_m_occ_boys loc_m_vir_boys;;\n",
|
||||
"(*let new_m_boys = localise localisation m_C \"boys\" 1. 100 10e-7;;\n",
|
||||
"let new_m_er = localise localisation m_C \"ER\" 1. 100 10e-7;;\n",
|
||||
"*)\n",
|
||||
"\n",
|
||||
"let loc_m_occ_boys = localise localisation m_occ \"Boys\" 1. 1000 10e-7;;\n",
|
||||
"\n",
|
||||
"(*\n",
|
||||
"let loc_m_occ_er = localisation m_occ \"ER\" 1. 100 0. 10e-7;;\n",
|
||||
"let loc_m_vir_er = localisation m_vir \"ER\" 1. 100 0. 10e-7;;\n",
|
||||
"let loc_m_vir_boys = localise localisation m_vir \"boys\" 1. 100 10e-7;;\n",
|
||||
"let m_assemble_boys = assemble loc_m_occ_boys loc_m_vir_boys;;\n",
|
||||
"*)\n",
|
||||
"\n",
|
||||
"(*\n",
|
||||
"let loc_m_occ_er = localise localisation m_occ \"ER\" 1. 100 10e-7;;\n",
|
||||
"let loc_m_vir_er = localise localisation m_vir \"ER\" 1. 100 10e-7;;\n",
|
||||
"let m_assemble_er = assemble loc_m_occ_er loc_m_vir_er;;*)\n",
|
||||
"(*\n",
|
||||
"let loc_assemble_boys = localisation m_assemble_boys \"boys\" 1. 100 0. 10e-7;;\n",
|
||||
"let loc_assemble_er = localisation m_assemble_er \"er\" 1. 100 0. 10e-7;;\n",
|
||||
"*)"
|
||||
"let loc_assemble_boys = localise localisation m_assemble_boys \"boys\" 1. 100 10e-7;;\n",
|
||||
"let loc_assemble_er = localise localisation m_assemble_er \"er\" 1. 100 10e-7;;*)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
226
Test.ipynb
226
Test.ipynb
@ -1,226 +0,0 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"#use \"topfind\";;\n",
|
||||
"#require \"jupyter.notebook\";;\n",
|
||||
"#require \"lacaml.top\";;\n",
|
||||
"#require \"alcotest\";;\n",
|
||||
"#require \"str\";;\n",
|
||||
"#require \"bigarray\";;\n",
|
||||
"#require \"zarith\";;\n",
|
||||
"#require \"getopt\";;\n",
|
||||
"open Lacaml.D"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"let n_ao = 8;;\n",
|
||||
"let n_mo = 6;; \n",
|
||||
"let ran=\n",
|
||||
"Mat.random ~range:1. ~from:0. n_ao n_mo;; "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"(* Extraction des colonnes i,j,k,... d'une matrice à partir d'une liste [i,j,k,...] *)\n",
|
||||
"\n",
|
||||
"let toto = [1;2;3];;\n",
|
||||
"(*\n",
|
||||
"ran;;\n",
|
||||
"let new_ran = Mat.transpose_copy ran ;;\n",
|
||||
"\n",
|
||||
"let vec = Mat.to_col_vecs ran;;\n",
|
||||
"\n",
|
||||
"vec.(0);;\n",
|
||||
"\n",
|
||||
"let f a = vec.(a);;\n",
|
||||
"\n",
|
||||
"let n = List.map f toto;;\n",
|
||||
"\n",
|
||||
"let vec_list = [vec.(0);vec.(1)];;\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"let mat_n = Mat.of_col_vecs_list vec_list;;\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"let occ ran toto = \n",
|
||||
" let new_ran = Mat.transpose_copy ran\n",
|
||||
" in\n",
|
||||
" let vec = Mat.to_col_vecs new_ran\n",
|
||||
" in \n",
|
||||
" let f a = vec.(a+1)\n",
|
||||
" in \n",
|
||||
" let vec_list = List.map f toto \n",
|
||||
"in Mat.of_col_vecs_list vec_list;;\n",
|
||||
"\n",
|
||||
"occ ran toto;;\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"let list_a = [0;0;2;0;5];;\n",
|
||||
"\n",
|
||||
"let new_list list= List.filter (fun x -> x > 0.) list;;\n",
|
||||
"\n",
|
||||
"let vecto = Vec.init 8 (fun i -> if List.mem i toto\n",
|
||||
"then 0.\n",
|
||||
"else float_of_int(i) );;\n",
|
||||
"\n",
|
||||
"let vecto_list = Vec.to_list vecto;;\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"new_list vecto_list;;\n",
|
||||
"*)\n",
|
||||
"(******************)\n",
|
||||
"(*\n",
|
||||
"ran;;\n",
|
||||
"let vec_of_mat = Mat.to_col_vecs ran;;\n",
|
||||
"let f a = vec_of_mat.(a-1);;\n",
|
||||
"vec_of_mat.(5);;\n",
|
||||
"let vec_list = List.map f toto;;\n",
|
||||
"let new_m = Mat.of_col_vecs_list vec_list;;\n",
|
||||
"*)\n",
|
||||
"\n",
|
||||
"(* Fp *)\n",
|
||||
"let miss_elem mat list = \n",
|
||||
" let n_mo = Mat.dim2 mat\n",
|
||||
" in\n",
|
||||
" let vec = Vec.init (n_mo) (fun i ->\n",
|
||||
" if List.mem i list\n",
|
||||
" then 0.\n",
|
||||
" else float_of_int(i))\n",
|
||||
" in\n",
|
||||
" let vec_list = Vec.to_list vec\n",
|
||||
" in\n",
|
||||
" let g a = int_of_float(a)\n",
|
||||
" in\n",
|
||||
" let vec_list_int = List.map g vec_list\n",
|
||||
" \n",
|
||||
" in\n",
|
||||
" List.filter (fun x -> x > 0) vec_list_int;;\n",
|
||||
"\n",
|
||||
"let split_mat mat list =\n",
|
||||
" let vec_of_mat = Mat.to_col_vecs mat\n",
|
||||
" in\n",
|
||||
" let f a = vec_of_mat.(a-1)\n",
|
||||
" in\n",
|
||||
" let vec_list_1 = List.map f list\n",
|
||||
" in\n",
|
||||
" let list_2 = miss_elem mat list\n",
|
||||
" in\n",
|
||||
" let vec_list_2 = List.map f list_2\n",
|
||||
"in (Mat.of_col_vecs_list vec_list_1,Mat.of_col_vecs_list vec_list_2);; \n",
|
||||
"\n",
|
||||
"let m_occ , m_vir = split_mat ran toto;;\n",
|
||||
"\n",
|
||||
"(*\n",
|
||||
"let miss_elem mat list = \n",
|
||||
" let n_mo = Mat.dim2 mat\n",
|
||||
" in\n",
|
||||
" let vec = Vec.init (n_mo) (fun i ->\n",
|
||||
" if List.mem i list\n",
|
||||
" then 0.\n",
|
||||
" else float_of_int(i))\n",
|
||||
" in\n",
|
||||
" let vec_list = Vec.to_list vec\n",
|
||||
" in\n",
|
||||
" let g a = int_of_float(a)\n",
|
||||
" in\n",
|
||||
" let vec_list_int = List.map g vec_list\n",
|
||||
" \n",
|
||||
" in\n",
|
||||
" List.filter (fun x -> x > 0) vec_list_int;;\n",
|
||||
"*) \n",
|
||||
"\n",
|
||||
" \n",
|
||||
"\n",
|
||||
"(*let tata = miss_elem toto;;\n",
|
||||
"\n",
|
||||
"let titi = [1.;2.]\n",
|
||||
"\n",
|
||||
"let f a = int_of_float(a);;\n",
|
||||
"let test list = List.map f list;;\n",
|
||||
"\n",
|
||||
"test titi;;\n",
|
||||
"*)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"let m_occ , m_vir = split_mat ran toto;;"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"let nocc = n_mo / 2;;\n",
|
||||
"\n",
|
||||
"(* Fonction de rassemblement de 2 matrices *)\n",
|
||||
"let assemble = Mat.init_cols n_ao n_mo ( fun i j ->\n",
|
||||
" if j > nocc \n",
|
||||
" then m_vir.{i,j-nocc}\n",
|
||||
" else m_occ.{i,j})\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"let tutu = List.init nocc (fun i -> i)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "OCaml 4.10.0",
|
||||
"language": "OCaml",
|
||||
"name": "ocaml-jupyter"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": "text/x-ocaml",
|
||||
"file_extension": ".ml",
|
||||
"mimetype": "text/x-ocaml",
|
||||
"name": "OCaml",
|
||||
"nbconverter_exporter": null,
|
||||
"pygments_lexer": "OCaml",
|
||||
"version": "4.10.0"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
38
Work.ipynb
38
Work.ipynb
@ -1837,7 +1837,7 @@
|
||||
" let alpha = (alphaij.alpha_max) *. epsilon \n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" (*Printf.printf \"%f\\n%!\" alpha;*)\n",
|
||||
" (*Printf.printf \"%f\\n%!\" alpha;*)\n",
|
||||
"\n",
|
||||
" (* Indice i et j du alpha max après calcul *)\n",
|
||||
" let indice_i = alphaij.indice_ii \n",
|
||||
@ -1845,48 +1845,49 @@
|
||||
" let indice_j = alphaij.indice_jj \n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" (*Printf.printf \"%i %i\\n%!\" indice_i indice_j;*)\n",
|
||||
" (*Printf.printf \"%i %i\\n%!\" indice_i indice_j;*)\n",
|
||||
"\n",
|
||||
" (* Matrice de rotation *)\n",
|
||||
" let m_R = f_R alpha \n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" (*Util.debug_matrix \"m_R\" m_R;*)\n",
|
||||
" (*Util.debug_matrix \"m_R\" m_R;*)\n",
|
||||
"\n",
|
||||
" (* Matrice qui va subir la rotation *)\n",
|
||||
" let m_Ksi = f_Ksi indice_i indice_j m_C \n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" (*Util.debug_matrix \"m_Ksi\" m_Ksi;*)\n",
|
||||
" (*Util.debug_matrix \"m_Ksi\" m_Ksi;*)\n",
|
||||
"\n",
|
||||
" (* Matrice ayant subit la rotation *)\n",
|
||||
" let m_Ksi_tilde = f_Ksi_tilde m_R m_Ksi m_C \n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" (*Util.debug_matrix \"m_Ksi_tilde\" m_Ksi_tilde;*)\n",
|
||||
" (*Util.debug_matrix \"m_Ksi_tilde\" m_Ksi_tilde;*)\n",
|
||||
"\n",
|
||||
" (* Matrice pour supprimerles coef des orbitales i et j dans la matrice des coef *)\n",
|
||||
" let m_Psi = f_k m_Ksi indice_i indice_j m_C\n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" (*Util.debug_matrix \"m_Psi\" m_Psi;*)\n",
|
||||
" (*Util.debug_matrix \"m_Psi\" m_Psi;*)\n",
|
||||
"\n",
|
||||
" (* Matrice pour ajouter les coef des orbitales i~ et j~ dans la matrice des coef *)\n",
|
||||
" let m_Psi_tilde = f_k m_Ksi_tilde indice_i indice_j m_C \n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" (*Util.debug_matrix \"m_Psi_tilde\" m_Psi_tilde;*)\n",
|
||||
" (*Util.debug_matrix \"m_Psi_tilde\" m_Psi_tilde;*)\n",
|
||||
"\n",
|
||||
" (* Matrice avec les coef des orbitales i et j remplacés par 0 *)\n",
|
||||
" let m_interm = f_interm m_C m_Psi \n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" (*Util.debug_matrix \"m_interm\" m_interm;*)\n",
|
||||
" (*Util.debug_matrix \"m_interm\" m_interm;*)\n",
|
||||
"\n",
|
||||
" (* Matrice après rotation *)\n",
|
||||
" (Mat.add m_Psi_tilde m_interm, alpha)\n",
|
||||
"\n",
|
||||
" in\n",
|
||||
" (* Extraction de la nouvelle matrice des coef et du alpha_max *)\n",
|
||||
" let m_new_m_C, alpha_max = new_m_C m_C methode prev_m_alpha epsilon\n",
|
||||
" in\n",
|
||||
"\n",
|
||||
@ -1900,22 +1901,22 @@
|
||||
" \n",
|
||||
" (* Critères possibles de localisation -> norme_alpha, moyenne_alpha, alpha, diff *)\n",
|
||||
" \n",
|
||||
" (* Norme de m_alpha *)\n",
|
||||
" (* Norme de m_alpha, moyenne et max *)\n",
|
||||
" let norme_alpha = norme m_alpha\n",
|
||||
" in\n",
|
||||
" let moyenne_alpha = norme_alpha /. (float_of_int((Mat.dim1 m_C)* (Mat.dim2 m_C)))\n",
|
||||
" in\n",
|
||||
" (* Valeur du alpha_max *)\n",
|
||||
" let alpha = alpha_max /. epsilon\n",
|
||||
" in\n",
|
||||
" \n",
|
||||
" (* D critère à maximiser *)\n",
|
||||
" let critere_D = alphad.d \n",
|
||||
" in\n",
|
||||
" let diff = max_D -. critere_D \n",
|
||||
" in\n",
|
||||
" \n",
|
||||
" (*Printf.printf \"%f\\n%!\" diff;*)\n",
|
||||
" Printf.printf \"%i %f %f %f %f %f\\n%!\" n max_D critere_D alpha norme_alpha moyenne_alpha;\n",
|
||||
" (*Printf.printf \"%f\\n%!\" diff;*)\n",
|
||||
" Printf.printf \"%i %f %f %f %f %f\\n%!\" n max_D critere_D alpha norme_alpha moyenne_alpha;\n",
|
||||
" \n",
|
||||
" (* Stabilisation de la convergence *)\n",
|
||||
"\n",
|
||||
@ -1930,15 +1931,14 @@
|
||||
" else let epsilon = 1.\n",
|
||||
" in\n",
|
||||
" \n",
|
||||
"(*Util.debug_matrix \"new_alpha_m\" m_alpha;*)\n",
|
||||
"(*Util.debug_matrix \"m_new_m_C\" m_new_m_C;*)\n",
|
||||
" (*Util.debug_matrix \"new_alpha_m\" m_alpha;*)\n",
|
||||
" (*Util.debug_matrix \"m_new_m_C\" m_new_m_C;*)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"(* Critère de conv pour sortir *)\n",
|
||||
"if diff**2. < cc**2.\n",
|
||||
" then m_new_m_C\n",
|
||||
" else\n",
|
||||
"localisation m_new_m_C methode epsilon (n-1) critere_D m_alpha cc max_D;;\n"
|
||||
" (* Critère de conv pour sortir *)\n",
|
||||
" if diff**2. < cc**2.\n",
|
||||
" then m_new_m_C\n",
|
||||
" else localisation m_new_m_C methode epsilon (n-1) critere_D m_alpha cc max_D;;"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -1369,7 +1369,7 @@
|
||||
" let alpha = (alphaij.alpha_max) *. epsilon \n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" (*Printf.printf \"%f\\n%!\" alpha;*)\n",
|
||||
" (*Printf.printf \"%f\\n%!\" alpha;*)\n",
|
||||
"\n",
|
||||
" (* Indice i et j du alpha max après calcul *)\n",
|
||||
" let indice_i = alphaij.indice_ii \n",
|
||||
@ -1377,48 +1377,49 @@
|
||||
" let indice_j = alphaij.indice_jj \n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" (*Printf.printf \"%i %i\\n%!\" indice_i indice_j;*)\n",
|
||||
" (*Printf.printf \"%i %i\\n%!\" indice_i indice_j;*)\n",
|
||||
"\n",
|
||||
" (* Matrice de rotation *)\n",
|
||||
" let m_R = f_R alpha \n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" (*Util.debug_matrix \"m_R\" m_R;*)\n",
|
||||
" (*Util.debug_matrix \"m_R\" m_R;*)\n",
|
||||
"\n",
|
||||
" (* Matrice qui va subir la rotation *)\n",
|
||||
" let m_Ksi = f_Ksi indice_i indice_j m_C \n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" (*Util.debug_matrix \"m_Ksi\" m_Ksi;*)\n",
|
||||
" (*Util.debug_matrix \"m_Ksi\" m_Ksi;*)\n",
|
||||
"\n",
|
||||
" (* Matrice ayant subit la rotation *)\n",
|
||||
" let m_Ksi_tilde = f_Ksi_tilde m_R m_Ksi m_C \n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" (*Util.debug_matrix \"m_Ksi_tilde\" m_Ksi_tilde;*)\n",
|
||||
" (*Util.debug_matrix \"m_Ksi_tilde\" m_Ksi_tilde;*)\n",
|
||||
"\n",
|
||||
" (* Matrice pour supprimerles coef des orbitales i et j dans la matrice des coef *)\n",
|
||||
" let m_Psi = f_k m_Ksi indice_i indice_j m_C\n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" (*Util.debug_matrix \"m_Psi\" m_Psi;*)\n",
|
||||
" (*Util.debug_matrix \"m_Psi\" m_Psi;*)\n",
|
||||
"\n",
|
||||
" (* Matrice pour ajouter les coef des orbitales i~ et j~ dans la matrice des coef *)\n",
|
||||
" let m_Psi_tilde = f_k m_Ksi_tilde indice_i indice_j m_C \n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" (*Util.debug_matrix \"m_Psi_tilde\" m_Psi_tilde;*)\n",
|
||||
" (*Util.debug_matrix \"m_Psi_tilde\" m_Psi_tilde;*)\n",
|
||||
"\n",
|
||||
" (* Matrice avec les coef des orbitales i et j remplacés par 0 *)\n",
|
||||
" let m_interm = f_interm m_C m_Psi \n",
|
||||
" in\n",
|
||||
"\n",
|
||||
" (*Util.debug_matrix \"m_interm\" m_interm;*)\n",
|
||||
" (*Util.debug_matrix \"m_interm\" m_interm;*)\n",
|
||||
"\n",
|
||||
" (* Matrice après rotation *)\n",
|
||||
" (Mat.add m_Psi_tilde m_interm, alpha)\n",
|
||||
"\n",
|
||||
" in\n",
|
||||
" (* Extraction de la nouvelle matrice des coef et du alpha_max *)\n",
|
||||
" let m_new_m_C, alpha_max = new_m_C m_C methode prev_m_alpha epsilon\n",
|
||||
" in\n",
|
||||
"\n",
|
||||
@ -1432,14 +1433,14 @@
|
||||
" \n",
|
||||
" (* Critères possibles de localisation -> norme_alpha, moyenne_alpha, alpha, diff *)\n",
|
||||
" \n",
|
||||
" (* Norme de m_alpha *)\n",
|
||||
" (* Norme de m_alpha, moyenne et max *)\n",
|
||||
" let norme_alpha = norme m_alpha\n",
|
||||
" in\n",
|
||||
" let moyenne_alpha = norme_alpha /. (float_of_int((Mat.dim1 m_C)* (Mat.dim2 m_C)))\n",
|
||||
" in\n",
|
||||
" (* Valeur du alpha_max *)\n",
|
||||
" let alpha = alpha_max /. epsilon\n",
|
||||
" in\n",
|
||||
" \n",
|
||||
" (* D critère à maximiser *)\n",
|
||||
" let critere_D = alphad.d \n",
|
||||
" in\n",
|
||||
|
Loading…
Reference in New Issue
Block a user