BCLS: Bound Constrained Least Squares

Version 0.1

bcdebug.c

Go to the documentation of this file.
00001 /* bcdebug.c
00002    $Revision$ $Date$
00003 
00004    ----------------------------------------------------------------------
00005    This file is part of BCLS (Bound-Constrained Least Squares).
00006 
00007    Copyright (C) 2006 Michael P. Friedlander, Department of Computer
00008    Science, University of British Columbia, Canada. All rights
00009    reserved. E-mail: <mpf@cs.ubc.ca>.
00010    
00011    BCLS is free software; you can redistribute it and/or modify it
00012    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    BCLS is distributed in the hope that it will be useful, but WITHOUT
00017    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00018    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
00019    Public License for more details.
00020    
00021    You should have received a copy of the GNU Lesser General Public
00022    License along with BCLS; if not, write to the Free Software
00023    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
00024    USA
00025    ----------------------------------------------------------------------
00026 */
00032 #include "bclib.h"
00033 
00034 unsigned long long int hashd(double x)
00035 {
00036     union 
00037     { 
00038         unsigned long long int i;
00039         double d; 
00040     } u;
00041     if (x == 0.0)
00042         return 0ULL;
00043     u.d = x;
00044     return u.i;
00045 }
00046 
00047 unsigned long long int hashiv(const int n, int x[])
00048 {
00049     unsigned long long int sum = 0ULL;
00050     int j;
00051     if (!x)
00052         return sum;
00053     for (j = 0; j < n; j++) {
00054         if (x[j] == 0)
00055             ; // Relax.
00056         else
00057             sum += (unsigned long long int)x[j];
00058     }
00059     return sum;
00060 }
00061 
00062 unsigned long long int hashdv(const int n, double x[])
00063 {
00064     union 
00065     { 
00066         unsigned long long int i;
00067         double d; 
00068     } u;
00069     unsigned long long int sum = 0ULL;
00070     int j;
00071     if (!x)
00072         return sum;
00073     for (j = 0; j < n; j++) {
00074         if (x[j] == 0.0)
00075             ; // Relax.
00076         else {
00077             u.d  = x[j];
00078             sum += u.i;
00079         }
00080     }
00081     return sum;
00082 }
00083 
00084 unsigned long long int hashls( BCLS *ls )
00085 {
00086     unsigned long long int sum = 0ULL;
00087     int
00088         n  = ls->n,
00089         m  = ls->m,
00090         nm = n + m;
00091 
00092     sum += n + m + nm;
00093     sum += hashdv(n  , ls->anorm);
00094     sum += hashdv(n  , ls->x);
00095     sum += hashdv(m  , ls->b);
00096     sum += hashdv(n  , ls->c);
00097     sum += hashdv(n  , ls->bl);
00098     sum += hashdv(n  , ls->bu);
00099     sum += hashdv(nm , ls->r);
00100     sum += hashdv(n  , ls->g);
00101     sum += hashdv(n  , ls->dx);
00102     sum += hashdv(n  , ls->dxFree);
00103     sum += hashdv(n  , ls->aBreak);
00104     sum += hashiv(n  , ls->iBreak);
00105     sum += hashiv(n  , ls->ix);
00106     sum += hashdv(nm , ls->wrk_u);
00107     sum += hashdv(nm , ls->wrk_v);
00108     sum += hashdv(nm , ls->wrk_w);
00109 
00110     return sum;
00111 }

Generated on Sun Mar 4 22:50:03 2007 by Doxygen 1.5.1