- Main Page
- Related Pages
- Classes
- Files

# messaget.h

    00001 //
    00002 // messaget.h
    00003 //
    00004 // Copyright (C) 1996 Limit Point Systems, Inc.
    00005 //
    00006 // Author: Curtis Janssen <cljanss@limitpt.com>
    00007 // Maintainer: LPS
    00008 //
    00009 // This file is part of the SC Toolkit.
    00010 //
    00011 // The SC Toolkit is free software; you can redistribute it and/or modify
    00012 // it under the terms of the GNU Library General Public License as published by
    00013 // the Free Software Foundation; either version 2, or (at your option)
    00014 // any later version.
    00015 //
    00016 // The SC Toolkit is distributed in the hope that it will be useful,
    00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00019 // GNU Library General Public License for more details.
    00020 //
    00021 // You should have received a copy of the GNU Library General Public License
    00022 // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
    00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
    00024 //
    00025 // The U.S. Government is granted a limited license as per AL 91-7.
    00026 //
    00027
    00028 #ifndef _util_group_messaget_h
    00029 #define _util_group_messaget_h
    00030
    00031 #ifdef __GNUC__
    00032 #pragma implementation
    00033 #endif
    00034
    00035 #include <util/group/message.h>
    00036
    00037 namespace sc {
    00038
    00039 template <class T>
    00040 void
    00041 GrpSumReduce<T>::reduce(T*target, T*data, int nelement)
    00042 {
    00043   for (int i=0; i<nelement; i++) {
    00044       target[i] += data[i];
    00045     }
    00046 }
    00047
    00048 template <class T>
    00049 void
    00050 GrpMinReduce<T>::reduce(T*target, T*data, int nelement)
    00051 {
    00052   for (int i=0; i<nelement; i++) {
    00053       if (target[i] > data[i]) target[i] = data[i];
    00054     }
    00055 }
    00056
    00057 template <class T>
    00058 void
    00059 GrpMaxReduce<T>::reduce(T*target, T*data, int nelement)
    00060 {
    00061   for (int i=0; i<nelement; i++) {
    00062       if (target[i] < data[i]) target[i] = data[i];
    00063     }
    00064 }
    00065
    00066 template <class T>
    00067 void
    00068 GrpArithmeticAndReduce<T>::reduce(T*target, T*data, int nelement)
    00069 {
    00070   for (int i=0; i<nelement; i++) {
    00071       target[i] = target[i] & data[i];
    00072     }
    00073 }
    00074
    00075 template <class T>
    00076 void
    00077 GrpArithmeticOrReduce<T>::reduce(T*target, T*data, int nelement)
    00078 {
    00079   for (int i=0; i<nelement; i++) {
    00080       target[i] = target[i] | data[i];
    00081     }
    00082 }
    00083
    00084 template <class T>
    00085 void
    00086 GrpArithmeticXOrReduce<T>::reduce(T*target, T*data, int nelement)
    00087 {
    00088   for (int i=0; i<nelement; i++) {
    00089       target[i] = target[i] ^ data[i];
    00090     }
    00091 }
    00092
    00093 template <class T>
    00094 void
    00095 GrpProductReduce<T>::reduce(T*target, T*data, int nelement)
    00096 {
    00097   for (int i=0; i<nelement; i++) {
    00098       target[i] *= data[i];
    00099     }
    00100 }
    00101
    00102 template <class T>
    00103 void
    00104 GrpFunctionReduce<T>::reduce(T*target, T*data, int nelement)
    00105 {
    00106   (*func_)(target,data,nelement);
    00107 }
    00108
    00109 }
    00110
    00111 #endif
    00112
    00114
    00115 // Local Variables:
    00116 // mode: c++
    00117 // c-file-style: "CLJ"
    00118 // End: