MOOCHO (Single Doxygen Collection) Version of the Day
RTOp_reduct_sum_values.c
Go to the documentation of this file.
00001 /*
00002 // @HEADER
00003 // ***********************************************************************
00004 // 
00005 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
00006 //                  Copyright (2003) Sandia Corporation
00007 // 
00008 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00009 // license for use of this work by or on behalf of the U.S. Government.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //  
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA
00025 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00026 // 
00027 // ***********************************************************************
00028 // @HEADER
00029 */
00030 
00031 #include "RTOp_reduct_sum_values.h"
00032 
00033 int RTOp_reduct_sum_values(
00034   const struct RTOp_RTOp_vtbl_t* vtbl, const void* obj_data
00035   , RTOp_ReductTarget in_targ_obj, RTOp_ReductTarget inout_targ_obj )
00036 {
00037   int num_values, k;
00038 #ifdef RTOp_DEBUG
00039   assert(obj_data);
00040 #endif
00041   num_values = *(RTOp_index_type*)obj_data;
00042   /* inout_dot_prod += in_dot_prod */
00043   for( k = 0; k < num_values; ++k )
00044     ((RTOp_value_type*)inout_targ_obj)[k] += ((RTOp_value_type*)in_targ_obj)[k];
00045   return 0;
00046 }
00047 
00048 static void CALL_API external_reduct_op( void* in_targ_array, void* inout_targ_array
00049   , int* len, RTOp_Datatype* datatype )
00050 {
00051   /* inout_dot_prod += in_dot_prod */
00052   RTOp_index_type
00053     num_values   = *(RTOp_value_type*)in_targ_array; /* num_values is first size member */
00054   RTOp_value_type /* index past the size members */
00055     *in_targs    = (RTOp_value_type*)in_targ_array    + 3,
00056     *inout_targs = (RTOp_value_type*)inout_targ_array + 3;
00057   int i, k;
00058   for( i = 0; i < *len; ++i, inout_targs += (3 + num_values), in_targs += (3 + num_values) ) {
00059     for( k = 0; k < num_values; ++k )
00060       inout_targs[k] += in_targs[k];
00061   }
00062 }
00063 
00064 int RTOp_get_reduct_sum_values_op(
00065   const struct RTOp_RTOp_vtbl_t* vtbl, const void* obj_data
00066   , RTOp_reduct_op_func_ptr_t* reduct_op_func_ptr )
00067 {
00068   *reduct_op_func_ptr = external_reduct_op;
00069   return 0;
00070 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines