lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [4872] Simplify


From: Greg Chicares
Subject: [lmi-commits] [4872] Simplify
Date: Fri, 30 Apr 2010 01:21:18 +0000

Revision: 4872
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=4872
Author:   chicares
Date:     2010-04-30 01:21:18 +0000 (Fri, 30 Apr 2010)
Log Message:
-----------
Simplify

Modified Paths:
--------------
    lmi/trunk/ihs_dbvalue.cpp
    lmi/trunk/ihs_dbvalue.hpp

Modified: lmi/trunk/ihs_dbvalue.cpp
===================================================================
--- lmi/trunk/ihs_dbvalue.cpp   2010-04-29 23:51:30 UTC (rev 4871)
+++ lmi/trunk/ihs_dbvalue.cpp   2010-04-30 01:21:18 UTC (rev 4872)
@@ -123,25 +123,6 @@
 }
 
 //============================================================================
-TDBValue::TDBValue
-    (int                      a_key
-    ,int                      a_ndims
-    ,int const*               a_dims
-    ,double const*            a_data
-    ,std::vector<std::string> a_extra_axes_names
-    ,std::vector<double>      a_extra_axes_values
-    )
-    :key(a_key)
-    ,extra_axes_names(a_extra_axes_names)
-    ,extra_axes_values(a_extra_axes_values)
-{
-    axis_lengths    .assign(a_dims, a_dims + a_ndims);
-    data_values     .assign(a_data, a_data + getndata());
-
-    ParanoidCheck();
-}
-
-//============================================================================
 TDBValue::TDBValue(TDBValue const& obj)
     :key          (obj.key)
     ,axis_lengths (obj.axis_lengths)
@@ -264,7 +245,6 @@
         if(1 != axis_lengths[j])
             {
             LMI_ASSERT(a_idx[j] < axis_lengths[j]);
-            // TODO ?? Here gcc warns of assignment to unsigned int from 
double.
             z = z * axis_lengths[j] + a_idx[j];
             }
         }
@@ -285,26 +265,7 @@
 //============================================================================
 double const* TDBValue::operator[](TDBIndex const& a_idx) const
 {
-/*
-            tiered_product<double>()
-                (assets
-                ,TieredMEBands
-                ,TieredMECharges
-                )
-
-        std::vector<double>::difference_type dist(0);
-        distance(CSVBegin, CSVEnd, dist);
-
-    // The first six axes are fixed.
-    // Preprocess the others.
-    // TODO ?? use std::find(), lower_bound, tiered_product...
-
-    std::vector<double>     extra_axes_values;
-    std::vector<e_IdxType>  extra_axes_types;
-*/
-
     std::vector<double>idx(a_idx.GetIdx());
-// TODO ?? FixupIndex(idx); // Doesn't work.
 
     LMI_ASSERT(0 < axis_lengths.size());
     int z = 0;
@@ -474,68 +435,6 @@
 }
 
 //============================================================================
-void TDBValue::FixupIndex(std::vector<double>& idx) const
-{
-    std::vector<double>::iterator           i_idx = idx.begin();
-    // debugging
-    if(idx.size() <= e_number_of_axes)
-        {
-        return;
-        }
-    std::advance(i_idx, e_number_of_axes - 1);
-//  std::vector<double>::const_iterator     i_val = extra_axes_values.begin();
-    std::vector<e_IdxType>::const_iterator  i_typ = extra_axes_types.begin();
-    while(i_idx < idx.end())
-        {
-        switch(*i_typ)
-            {
-            case e_Offset:
-                {
-                // do nothing
-                }
-                break;
-            case e_Discrete:
-                {
-                std::vector<double>::const_iterator z = std::find
-                    (extra_axes_values.begin()
-                    ,extra_axes_values.end()
-                    ,*i_idx
-                    );
-                *i_idx = z - extra_axes_values.begin();
-                }
-                break;
-            case e_LowBound:
-                {
-                std::vector<double>::const_iterator z = std::lower_bound
-                    (extra_axes_values.begin()
-                    ,extra_axes_values.end()
-                    ,*i_idx
-                    );
-                *i_idx = z - extra_axes_values.begin();
-                }
-                break;
-
-            case e_Incremental:
-                {
-                // TODO ?? What to do here?
-                }
-                break;
-            default:
-                fatal_error()
-                    << "Unknown axis type "
-                    << *i_typ
-                    << '.'
-                    << LMI_FLUSH
-                    ;
-                break;
-            }
-        i_idx++;
-//      i_val++; // TODO ?? Need std::vector of vectors?
-        i_typ++;
-        }
-}
-
-//============================================================================
 // TODO ?? Combine this with ParanoidCheck()?
 bool TDBValue::AreAllAxesOK() const
 {
@@ -586,7 +485,6 @@
 }
 
 //============================================================================
-// TODO ?? Isn't the following function useless?
 int TDBValue::GetNDims() const
 {
     return axis_lengths.size();
@@ -653,8 +551,6 @@
     xml_serialize::get_element(e, "key"              , short_name       );
     key = db_key_from_name(short_name);
     xml_serialize::get_element(e, "axis_lengths"     , axis_lengths     );
-    xml_serialize::get_element(e, "extra_axes_values", extra_axes_values);
-    xml_serialize::get_element(e, "extra_axes_names" , extra_axes_names );
     xml_serialize::get_element(e, "data_values"      , data_values      );
 
     LMI_ASSERT(getndata() == static_cast<int>(data_values.size()));
@@ -676,8 +572,6 @@
 
     xml_serialize::set_element(e, "key"              , db_name_from_key(key));
     xml_serialize::set_element(e, "axis_lengths"     , axis_lengths     );
-    xml_serialize::set_element(e, "extra_axes_values", extra_axes_values);
-    xml_serialize::set_element(e, "extra_axes_names" , extra_axes_names );
     xml_serialize::set_element(e, "data_values"      , data_values      );
 }
 

Modified: lmi/trunk/ihs_dbvalue.hpp
===================================================================
--- lmi/trunk/ihs_dbvalue.hpp   2010-04-29 23:51:30 UTC (rev 4871)
+++ lmi/trunk/ihs_dbvalue.hpp   2010-04-30 01:21:18 UTC (rev 4872)
@@ -38,17 +38,10 @@
 #include <string>
 #include <vector>
 
-// Value of an entry in the database dictionary.
-
-enum e_IdxType
-    {e_Offset
-    ,e_Discrete
-    ,e_LowBound
-    ,e_Incremental
-    };
-
 namespace xml_serialize {template<typename T> struct xml_io;}
 
+/// Value of an entry in the database dictionary.
+
 class LMI_SO TDBValue
 {
     friend std::istream& operator>>(std::istream&, TDBValue&);
@@ -85,14 +78,6 @@
         (int    a_key
         ,double a_datum
         );
-    TDBValue
-        (int                      a_key
-        ,int                      a_ndims
-        ,int const*               a_dims
-        ,double const*            a_data
-        ,std::vector<std::string> a_extra_axes_names
-        ,std::vector<double>      a_extra_axes_values
-        );
     TDBValue(TDBValue const&);
     TDBValue& operator=(TDBValue const&);
     virtual ~TDBValue();
@@ -113,15 +98,12 @@
 
     static std::vector<int> const& maximum_dimensions();
     static bool Equivalent(TDBValue const&, TDBValue const&);
-    // TODO ?? Experimental. If this turns out to be a good idea,
-    // then parameterize it.
     static bool VariesByState(TDBValue const&);
 
   private:
     int  getndata()                           const;
     void ParanoidCheck()                      const;
     bool AreAllAxesOK()                       const;
-    void FixupIndex(std::vector<double>& idx) const;
 
     void read (xml::element const&);
     void write(xml::element&) const;
@@ -143,17 +125,6 @@
     // consecutive durational elements in contiguous storage.
     std::vector<int>    axis_lengths;
     std::vector<double> data_values;
-
-    // For the first six axes, the allowable range of values is hardcoded;
-    // we know their names because they are fixed.
-    // We know the names of the first six axes because they are fixed,
-    // and we know their ranges of permissible values because they are
-    // hardcoded. For each custom axis, we need to specify its name and
-    // enumerate its of permissible values; its number of permissible
-    // values is in axis_lengths.
-    std::vector<std::string> extra_axes_names;
-    std::vector<double>      extra_axes_values;
-    std::vector<e_IdxType>   extra_axes_types;
 };
 
 /*





reply via email to

[Prev in Thread] Current Thread [Next in Thread]