Spaces:
Sleeping
Sleeping
Download data/macros/PDE/Disc_diff_oper45.sci from notsn/headless_scilab: direct link, hf CLI and curl.
- Browser
- Download file 2.37 kB
-
https://huggingface.co/spaces/notsn/headless_scilab/resolve/main/data/macros/PDE/Disc_diff_oper45.sci
- Command line
-
hf download hf://spaces/notsn/headless_scilab/data/macros/PDE/Disc_diff_oper45.sci
-
curl -L -o Disc_diff_oper45.sci https://huggingface.co/spaces/notsn/headless_scilab/resolve/main/data/macros/PDE/Disc_diff_oper45.sci
2.37 kB
| // Scicos | |
| // | |
| // Copyright (C) INRIA - Author : EADS-CCR | |
| // | |
| // This program is free software; you can redistribute it and/or modify | |
| // it under the terms of the GNU General Public License as published by | |
| // the Free Software Foundation; either version 2 of the License, or | |
| // (at your option) any later version. | |
| // | |
| // This program is distributed in the hope that it will be useful, | |
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| // GNU General Public License for more details. | |
| // | |
| // You should have received a copy of the GNU General Public License | |
| // along with this program; if not, write to the Free Software | |
| // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
| // | |
| // See the file ../license.txt | |
| // | |
| function M=Disc_diff_oper45(N,h,DF_type) | |
| // Cette fonction construit l'ecriture de la discretisation de l'operateur d2u/dtdx // | |
| // ou de l'operateur du/dx sous forme matricielle. // | |
| // sortie : // | |
| // - M (Double) : est la matrice elementaire de discretisation de l'operateur // | |
| // entrees : // | |
| // - N (Entier) : est le nombre de noeuds // | |
| // - h (Double) : est le pas de discretisation h= (b-a)/N (i.e x(i)= i* h) // | |
| // - DF_type (Entier) : 0 pour les differences finies centrees, 1 pour les // | |
| // decentrees a gauche et 2 pour les decentrees � droite // | |
| //----------------------------------------------------------------------------------// | |
| if ( DF_type == 0) then | |
| // cas centr�e : | |
| Mij=[[(1:N-1) (2:N)]',[(2:N) (1:N-1)]']; | |
| Mmn=[N, N]; | |
| Mval=[(1/(2*h))*ones(N-1,1); (-1/(2*h))*ones(N-1,1)]; | |
| M=sparse(Mij, Mval, Mmn); | |
| elseif ( DF_type == 1 | DF_type == 2) then | |
| // les cas d�centr�e | |
| Mij=[[(1:N) (2:N)]',[(1:N) (1:N-1)]']; | |
| Mmn=[N, N]; | |
| Mval=[(1/h)*ones(N,1); (-1/h)*ones(N-1,1)]; | |
| M=sparse(Mij, Mval, Mmn); | |
| if ( DF_type == 2) then | |
| M=-M'; | |
| end | |
| end | |
| endfunction | |