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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1974 - (hide annotations)
Thu Nov 6 02:40:10 2008 UTC (11 years ago) by jfenwick
File MIME type: text/plain
File size: 1963 byte(s)
Changing ZERO and ONE in Solver.h to PASO_ZERO and PASO_ONE.
Changed three static vars to #defines
1 gross 1639
2     /*******************************************************
3 ksteube 1811 *
4     * Copyright (c) 2003-2008 by University of Queensland
5     * Earth Systems Science Computational Center (ESSCC)
6     * http://www.uq.edu.au/esscc
7     *
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 gross 1639
14 ksteube 1811
15 gross 1639 #include "Common.h"
16     #include "Functions.h"
17     #include "PasoUtil.h"
18     #include "Solver.h"
19     /*
20     * generate Linear System (mainly for test purposes)
21     *
22     */
23     Paso_Function * Paso_Function_LinearSystem_alloc(Paso_SystemMatrix* A, double* b, Paso_Options* options)
24     {
25     Paso_Function * out=NULL;
26     Paso_Solver_setPreconditioner(A,options);
27     if (! Paso_noError()) return NULL;
28     out=MEMALLOC(1,Paso_Function);
29     if (! Paso_checkPtr(out)) {
30     out->kind=LINEAR_SYSTEM;
31     out->mpi_info=Paso_MPIInfo_getReference(A->mpi_info);
32     out->n=Paso_SystemMatrix_getTotalNumRows(A);
33 gross 1798 out->more=(void*)Paso_SystemMatrix_reference(A);
34 gross 1639 out->b=b;
35     out->tmp=MEMALLOC(out->n, double);
36     Paso_checkPtr(out->tmp);
37     }
38     if (Paso_noError()) {
39     return out;
40     } else {
41     Paso_Function_LinearSystem_free(out);
42     return NULL;
43     }
44     }
45     void Paso_Function_LinearSystem_free(Paso_Function * F)
46     {
47     if (F!=NULL) {
48     Paso_MPIInfo_free(F->mpi_info);
49     Paso_SystemMatrix_free((Paso_SystemMatrix*)(F->more));
50     MEMFREE(F->tmp);
51     MEMFREE(F);
52     }
53     }
54     /*
55     * evaluates value=P*(b-Ax)
56     *
57     */
58 gross 1804 err_t Paso_Function_LinearSystem_call(Paso_Function * F,double* value, const double* arg, Paso_Performance *pp)
59 gross 1639 {
60     Paso_SystemMatrix* A=(Paso_SystemMatrix*)(F->more);
61     Paso_Copy(F->n,F->tmp,F->b); /* tmp=b */
62 jfenwick 1974 Paso_SystemMatrix_MatrixVector_CSR_OFFSET0(PASO_ONE, A, arg,-PASO_ONE, F->tmp); /* tmp=(A*arg-tmp) */
63 gross 1798 Paso_Solver_solvePreconditioner(A,value,F->tmp); /* value=P*tmp */
64 gross 1639 return NO_ERROR;
65     }

  ViewVC Help
Powered by ViewVC 1.1.26