/[escript]/trunk/paso/src/Functions.c
ViewVC logotype

Annotation of /trunk/paso/src/Functions.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1476 - (hide annotations)
Mon Apr 7 23:38:50 2008 UTC (11 years, 6 months ago) by gross
File MIME type: text/plain
File size: 1358 byte(s)
Jacobian-free Newton method added to Paso
1 gross 1476 /* $Id:$ */
2    
3     /*******************************************************
4     *
5     * Copyright 2008 by University of Queensland
6     *
7     * http://esscc.uq.edu.au
8     * Primary Business: Queensland, Australia
9     * Licensed under the Open Software License version 3.0
10     * http://www.opensource.org/licenses/osl-3.0.php
11     *
12     *******************************************************/
13    
14     #include "Common.h"
15     #include "Functions.h"
16    
17     /*
18     * numerical calculation of the directional derivative J0w if F at x0 in the direction w. f0 is the value of F at x0.
19     * setoff is workspace
20     */
21    
22     err_t Paso_FunctionDerivative(double* J0w, const double* w, Paso_Function* F, const double *f0, const double *x0, double* setoff)
23     {
24     err_t err=0;
25     dim_t n=F->local_n;
26     double norm_w,epsnew,norm_x0;
27     epsnew=10.*sqrt(EPSILON);
28     norm_w=Paso_l2(n,w,F->mpi_info);
29    
30     if (norm_w>0) {
31     Paso_zeroes(n,J0w);
32     } else {
33     epsnew = epsnew/norm_w;
34     norm_x0=Paso_l2(n,x0,F->mpi_info);
35     if (norm_x0>0) epsnew*=norm_x0;
36     Paso_LinearCombination(n,setoff,1.,x0,epsnew,w);
37     err=Paso_FunctionCall(F,J0w,setoff);
38     if (err==0) {
39     Paso_Update(n,1./epsnew,J0w,-1./epsnew,f0); /* J0w = (J0w - f0)/epsnew; */
40     }
41     }
42     return err;
43     }
44    
45     err_t Paso_FunctionCall(Paso_Function * F,double* value, const double* arg)
46     {
47    
48     }
49    
50    
51    
52    
53    
54    

  ViewVC Help
Powered by ViewVC 1.1.26