Epetra Package Browser (Single Doxygen Collection) Development
Epetra_C_wrappers.h
Go to the documentation of this file.
00001 /*
00002 //@HEADER
00003 // ************************************************************************
00004 // 
00005 //               Epetra: Linear Algebra Services Package 
00006 //                 Copyright 2001 Sandia Corporation
00007 // 
00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009 // the U.S. Government retains certain rights in this software.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00039 // 
00040 // ************************************************************************
00041 //@HEADER
00042 */
00043 
00044 #ifndef EPETRA_C_WRAPPERS_H
00045 #define EPETRA_C_WRAPPERS_H
00046 
00047 #ifdef EPETRA_FORTRAN
00048 
00049 typedef double * EPETRA_DOUBLE;
00050 typedef int    * EPETRA_INT;
00051 #define EPETRA_DEREF(a) *a
00052 
00053 #ifdef EPETRA_ADDRESS64BIT
00054 
00055 typedef long int EPETRA_OBJECT_PTR;
00056 typedef long int & EPETRA_OBJECT_REF;
00057 
00058 #else
00059 
00060 typedef int EPETRA_OBJECT_PTR;
00061 typedef int & EPETRA_OBJECT_REF;
00062 
00063 #endif
00064 #else
00065 
00066 /* These typedefs act as new types for the Epetra C interface */
00067 
00068 typedef double EPETRA_DOUBLE;
00069 typedef int    EPETRA_INT;
00070 #define EPETRA_DEREF(a) a
00071 
00072 typedef void * EPETRA_OBJECT_PTR;
00073 typedef void * EPETRA_OBJECT_REF;
00074 
00075 
00076 #endif
00077  
00078 #ifdef EPETRA_FORTRAN
00079 #if defined(TRILINOS_HAVE_NO_FORTRAN_UNDERSCORE)
00080 #define MANGLE(x) x
00081 #else
00082 #define MANGLE(x) x ## __
00083 #endif
00084 #else
00085 #define MANGLE(x) x
00086 #endif
00087 
00088 
00089 
00090 #ifdef __cplusplus
00091 extern "C" {
00092 #endif
00093 
00094   /*****************************************************/
00096   /***************************************************/
00097 
00098 #ifdef EPETRA_MPI
00099   EPETRA_OBJECT_PTR MANGLE(epetra_mpicomm_create1)();
00100   EPETRA_OBJECT_PTR MANGLE(epetra_mpicomm_create2)(MPI_Comm * comm);
00101 #endif
00102   EPETRA_OBJECT_PTR MANGLE(epetra_serialcomm_create)();
00103 
00104   int MANGLE(epetra_comm_mypid)(EPETRA_OBJECT_REF communicator);
00105 
00106   int MANGLE(epetra_comm_numproc)(EPETRA_OBJECT_REF communicator);
00107 
00108   void MANGLE(epetra_comm_barrier)(EPETRA_OBJECT_REF communicator);
00109 
00110   void MANGLE(epetra_comm_destroy)(EPETRA_OBJECT_REF communicator);
00111 
00112   /*****************************************************/
00114   /***************************************************/
00115 
00116   EPETRA_OBJECT_PTR MANGLE(epetra_map_create1)(EPETRA_INT numGlobalEquations, 
00117                  EPETRA_INT indexBase,
00118                  EPETRA_OBJECT_REF comm);
00119 
00120   EPETRA_OBJECT_PTR MANGLE(epetra_map_create2)(EPETRA_INT numGlobalEquations, 
00121                  EPETRA_INT numMyElements,
00122                  EPETRA_INT indexBase,
00123                  EPETRA_OBJECT_REF comm);
00124 
00125   EPETRA_OBJECT_PTR MANGLE(epetra_map_create3)(EPETRA_INT numGlobalEquations, 
00126                  EPETRA_INT numlocalEquations,
00127                  int *updateList, EPETRA_INT indexBase,
00128                  EPETRA_OBJECT_REF comm);
00129   int MANGLE(epetra_map_nummyelements)(EPETRA_OBJECT_REF map);
00130   int MANGLE(epetra_map_numglobalelements)(EPETRA_OBJECT_REF map);
00131 
00132 #ifndef EPETRA_FORTRAN  /* Fortran cannot receive a pointer to int */
00133   int * MANGLE(epetra_map_myglobalelements)(EPETRA_OBJECT_REF map);
00134 #endif
00135 
00136   EPETRA_OBJECT_PTR MANGLE(epetra_map_comm)(EPETRA_OBJECT_REF map);
00137 
00138   void MANGLE(epetra_map_destroy)(EPETRA_OBJECT_REF map);
00139 
00140   /*****************************************************/
00142   /***************************************************/
00143 
00144   EPETRA_OBJECT_PTR MANGLE(epetra_vector_create1)(EPETRA_OBJECT_REF map);
00145   EPETRA_OBJECT_PTR MANGLE(epetra_vector_create2)(EPETRA_INT Copy, EPETRA_OBJECT_REF map,
00146               double * V);
00147 
00148   int MANGLE(epetra_vector_putscalar)(EPETRA_OBJECT_REF x, EPETRA_DOUBLE scalar);
00149 
00150   int MANGLE(epetra_vector_update)(EPETRA_OBJECT_REF x, EPETRA_DOUBLE scalara,
00151            EPETRA_OBJECT_REF a,
00152            EPETRA_DOUBLE scalarb, EPETRA_OBJECT_REF b,
00153            EPETRA_DOUBLE scalarx);
00154 
00155   int MANGLE(epetra_vector_norm1)(EPETRA_OBJECT_REF x, double *result);
00156 
00157   int MANGLE(epetra_vector_norm2)(EPETRA_OBJECT_REF x, double *result);
00158 
00159   int MANGLE(epetra_vector_random)(EPETRA_OBJECT_REF x);
00160 
00161   void MANGLE(epetra_vector_print)(EPETRA_OBJECT_REF x);
00162 
00163   void MANGLE(epetra_vector_destroy)(EPETRA_OBJECT_REF x);
00164 
00165 #ifdef SKIP4NOW
00166   /*****************************************************/
00168   /*****************************************************/
00169 
00170   EPETRA_OBJECT_PTR MANGLE(epetra_vbr_matrix_create)(EPETRA_OBJECT_REF rowmap);
00171 
00172   int MANGLE(epetra_vbr_matrix_allocate)(EPETRA_OBJECT_REF A, int* numNzBlks, int* blkColInds);
00173 
00174   int MANGLE(epetra_vbr_matrix_putblockrow)(EPETRA_OBJECT_REF A, EPETRA_INT
00175                blk_row, EPETRA_INT num_nz_blocks,
00176                double* vals, int* blk_col_inds);
00177 
00178   int MANGLE(epetra_vbr_matrix_fillcomplete)(EPETRA_OBJECT_REF A);
00179 
00180   int  MANGLE(epetra_vbr_matrix_matvec)(EPETRA_OBJECT_REF A, EPETRA_VECTOR x, EPETRA_VECTOR y);
00181 
00182   int MANGLE(epetra_vbr_matrix_matmultivec)(EPETRA_OBJECT_REF A,
00183                EPETRA_MULTIVECTOR x,
00184                EPETRA_MULTIVECTOR y);
00185 
00186   void MANGLE(epetra_vbr_matrix_destroy)(EPETRA_OBJECT_REF A);
00187 
00188   /*****************************************************/
00190   /*****************************************************/
00191 
00192   EPETRA_OBJECT_PTR MANGLE(epetra_crs_matrix_create)(EPETRA_OBJECT_REF rowmap);
00193 
00194   int  MANGLE(epetra_crs_matrix_allocate)(EPETRA_OBJECT_REF A, int* rowLengths);
00195 
00196   int MANGLE(epetra_crs_matrix_putrow)(EPETRA_OBJECT_REF A, EPETRA_INT row, 
00197           EPETRA_INT num_nz,
00198           double* vals, int* col_inds);
00199 
00200   int MANGLE(epetra_crs_matrix_sumintodiagonal)(EPETRA_OBJECT_REF A, 
00201              double* diagonal);
00202 
00203   int MANGLE(epetra_crs_matrix_fillcomplete)(EPETRA_OBJECT_REF A);
00204 
00205   int MANGLE(epetra_crs_matrix_matvec)(EPETRA_OBJECT_REF A, EPETRA_VECTOR x, 
00206           EPETRA_VECTOR y);
00207 
00208   int MANGLE(epetra_crs_matrix_matmultivec)(EPETRA_OBJECT_REF A,
00209                EPETRA_MULTIVECTOR x,
00210                EPETRA_MULTIVECTOR y);
00211 
00212   void MANGLE(epetra_crs_matrix_destroy)(EPETRA_OBJECT_REF A);
00213 
00214   /*****************************************************/
00216   /***************************************************/
00217 
00218   /* create empty shell WITHOUT float storage, fill later with put functions */
00219   EPETRA_OBJECT_PTR MANGLE(epetra_multivector_create)();
00220 
00221   /* create empty shell WITH float storage, fill later with put functions */
00222   EPETRA_OBJECT_PTR MANGLE(epetra_multivector_create1)(EPETRA_OBJECT_REF map, EPETRA_INT numvectors);
00223 
00224   /* Build multivector from a Fortran-style 2D array
00225      NOTE: User storage is not copied, user must keep A intact!! */
00226   EPETRA_OBJECT_PTR MANGLE(epetra_multivector_create2)(EPETRA_OBJECT_REF map,
00227                 double *A, EPETRA_INT lda, EPETRA_INT numvectors);
00228 
00229   /* Build multivector from a double **
00230      NOTE: User storage is not copied, user must keep A intact!! */
00231   EPETRA_OBJECT_PTR MANGLE(epetra_multivector_create3)(EPETRA_OBJECT_REF map,
00232                 double **in_multivector, EPETRA_INT numvectors);
00233 
00234   /* Copy constructor */
00235   EPETRA_OBJECT_PTR MANGLE(epetra_multivector_create4)(EPETRA_MULTIVECTOR
00236                 in_multivector);
00237 
00238   /* creates a new multivector from numvector number of vectors of an existing
00239    * multivector where the vectors to be copied are listed in
00240    * vecIndices.  
00241    */
00242   EPETRA_OBJECT_PTR MANGLE(epetra_multivector_create5)(EPETRA_MULTIVECTOR 
00243                 in_multivector, EPETRA_INT numvectors, int *vecIndices);
00244 
00245   EPETRA_OBJECT_PTR MANGLE(epetra_multivector_create6)(EPETRA_MULTIVECTOR
00246                 in_multiVector, EPETRA_INT startindex, EPETRA_INT numvectors);
00247 
00248   int MANGLE(epetra_multivector_putmultivector)(EPETRA_MULTIVECTOR multivector, 
00249             double **in_multivector);
00250 
00251   /* Allocates space for a multivector created by the default
00252    * constructor */
00253   int MANGLE(epetra_multivector_allocate)(EPETRA_MULTIVECTOR multivector, 
00254             EPETRA_OBJECT_REF map, EPETRA_INT numvectors);
00255 
00256   int MANGLE(epetra_multivector_putscalar)(EPETRA_MULTIVECTOR multivector, EPETRA_DOUBLE scalar);
00257 
00258   int MANGLE(epetra_multivector_scale)
00259        (EPETRA_MULTIVECTOR multiVector, EPETRA_DOUBLE scalar);
00260 
00261   int MANGLE(epetra_multivector_scalecopy)
00262        (EPETRA_MULTIVECTOR multiVector, EPETRA_MULTIVECTOR multiVector_in,
00263   EPETRA_DOUBLE scalar);
00264 
00265   int MANGLE(epetra_multivector_dotprod)
00266        (EPETRA_MULTIVECTOR multiVector, EPETRA_MULTIVECTOR multiVector_in,
00267   double *scalar);
00268 
00269   int MANGLE(epetra_multivector_addvec)
00270        (EPETRA_MULTIVECTOR multiVector, EPETRA_DOUBLE scalar, 
00271   EPETRA_MULTIVECTOR multiVector_in);
00272 
00273   int MANGLE(epetra_multivector_norm1)(EPETRA_MULTIVECTOR multivector, double *result);
00274 
00275   int MANGLE(epetra_multivector_norm2)(EPETRA_MULTIVECTOR multivector, double *result);
00276 
00277   int MANGLE(epetra_multivector_lincomb)(EPETRA_MULTIVECTOR multivector,
00278            EPETRA_MULTIVECTOR b, 
00279            EPETRA_DOUBLE scalar, EPETRA_MULTIVECTOR c);
00280 
00281   int MANGLE(epetra_multivector_random)(EPETRA_MULTIVECTOR multivector);
00282 
00283   /* Note: The return value for this function is the number of vectors
00284      in the multivector */
00285   int MANGLE(epetra_multivector_numvectors)(EPETRA_MULTIVECTOR multivector);
00286 
00287   int MANGLE(epetra_multivector_reduce)(EPETRA_MULTIVECTOR multivector);
00288 
00289   int MANGLE(eepetra_multivector_gemm)(EPETRA_MULTIVECTOR multivector,
00290                EPETRA_INT transa, EPETRA_INT transb, EPETRA_DOUBLE alpha,
00291                EPETRA_MULTIVECTOR A, EPETRA_MULTIVECTOR B,
00292                EPETRA_DOUBLE beta );
00293 
00294   void MANGLE(epetra_multivector_destroy)(EPETRA_MULTIVECTOR multivector);
00295 
00296   /*****************************************************/
00298   /***************************************************/
00299 
00300   EPETRA_OBJECT_PTR MANGLE(epetra_blockmap_create1)(
00301                 EPETRA_INT numGlobalEquations, EPETRA_INT numlocalEquations, int *updateList,
00302                 EPETRA_INT numGlobalblocks, EPETRA_INT numlocalblocks, int *blockUpdateList,
00303                 int* blockSizes, EPETRA_INT indexBase, EPETRA_COMM comm);
00304 
00305   EPETRA_OBJECT_PTR MANGLE(epetra_blockmap_create2)(
00306                 EPETRA_INT numGlobalblocks, EPETRA_INT numlocalblocks, int *blockUpdateList,
00307                 int* blockSizes, EPETRA_INT indexBase, EPETRA_COMM comm);
00308 
00309   void MANGLE(epetra_blockmap_destroy)(EPETRA_BLOCKMAP blockmap);
00310 
00311   /*****************************************************/
00313   /***************************************************/
00314 
00315   EPETRA_OBJECT_PTR MANGLE(epetra_localmap_create)(EPETRA_INT numlocalEquations,
00316                EPETRA_INT indexBase, EPETRA_COMM comm);
00317 
00318   void MANGLE(epetra_localmap_destroy)(EPETRA_LOCALMAP localmap);
00319 
00320   /*****************************************************/
00322   /***************************************************/
00323 
00324   EPETRA_OBJECT_PTR MANGLE(epetra_localblockmap_create1)(
00325                     EPETRA_INT numlocalEquations,
00326                     EPETRA_INT numlocalblocks,
00327                     int* blockSizes,
00328                     EPETRA_INT indexBase, EPETRA_COMM comm);
00329 
00330   EPETRA_OBJECT_PTR MANGLE(epetra_localblockmap_create2)(
00331                     EPETRA_INT numlocalblocks,
00332                     int* blockSizes,
00333                     EPETRA_INT indexBase, EPETRA_COMM comm);
00334 
00335   void MANGLE(epetra_localblockmap_destroy)(EPETRA_LOCALBLOCKMAP localblockmap);
00336 #endif /* 0 */
00337 
00338 #ifdef __cplusplus
00339 }
00340 #endif
00341 
00342 #endif /* EPETRA_C_WRAPPERS_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines