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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1479 - (show annotations)
Tue Apr 8 02:02:25 2008 UTC (11 years, 5 months ago) by artak
File MIME type: text/plain
File size: 1375 byte(s)
Unil.h header is added
1 /* $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 #include "Util.h"
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