[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Changeset]: octave_value(const ArrayN<octave_idx_type>&) constructor
From: |
David Bateman |
Subject: |
[Changeset]: octave_value(const ArrayN<octave_idx_type>&) constructor |
Date: |
Wed, 25 Jun 2008 13:49:14 +0200 |
User-agent: |
Thunderbird 2.0.0.12 (X11/20080306) |
The attached changeset adds a constructor for ArrayN<octave_idx_type>
that seems to me might be used whether indexes are created. It then uses
it in Flookup.
D.
--
David Bateman address@hidden
Motorola Labs - Paris +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin +33 6 72 01 06 33 (Mob)
91193 Gif-Sur-Yvette FRANCE +33 1 69 35 77 01 (Fax)
The information contained in this communication has been classified as:
[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary
# HG changeset patch
# User David Bateman <address@hidden>
# Date 1214394450 -7200
# Node ID 54f8e3ad246db8ab9daf0463dec9687278712fae
# Parent a3e7e24a6359c9c962390c6d364952d685eb1664
new octave_value constructor for ArrayN<octave_idx_type>
diff --git a/src/ChangeLog b/src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,11 @@ 2008-06-25 David Bateman <address@hidden
2008-06-25 David Bateman <address@hidden>
+ * ov.cc (octave_value const ArrayN<octave_idx_type)): New
+ constructor
+ * ov.h (octave_value const ArrayN<octave_idx_type)): Declare it.
+ * DLD-FUNCTIONS/lookup.cc (assign): Delete.
+ (Flookup): Use new octave_value constructors rather than assign.
+
* pr-output.cc (Frats): Print usage if nargin == 0.
2008-06-10 John W. Eaton <address@hidden>
diff --git a/src/DLD-FUNCTIONS/lookup.cc b/src/DLD-FUNCTIONS/lookup.cc
--- a/src/DLD-FUNCTIONS/lookup.cc
+++ b/src/DLD-FUNCTIONS/lookup.cc
@@ -47,25 +47,6 @@ contains_char (const std::string& str, c
{
return (str.find (c) != std::string::npos
|| str.find (std::toupper (c)) != std::string::npos);
-}
-
-// FIXME -- remove these one once octave_value supports octave_idx_type.
-static octave_value&
-assign (octave_value& ov, octave_idx_type idx)
-{
- double tmp = idx;
- ov = tmp;
- return ov;
-}
-
-static octave_value&
-assign (octave_value& ov, const ArrayN<octave_idx_type>& ida)
-{
- NDArray tmp (ida.dims ());
- for (int i = 0; i < ida.numel (); i++)
- tmp(i) = ida(i);
- ov = tmp;
- return ov;
}
// normal ascending comparator
@@ -239,8 +220,7 @@ For string lookup, 'i' indicates case-in
std::less<double> ());
}
- //retval(0) = idx;
- assign (retval(0), idx);
+ retval(0) = idx;
}
else if (str_case)
{
@@ -288,8 +268,7 @@ For string lookup, 'i' indicates case-in
idx(i) = bin_lookup (table.data (), table.length (), y(i),
std::ptr_fun (ov_str_comp));
- //retval(0) = idx;
- assign (retval(0), idx);
+ retval(0) = idx;
}
else
{
@@ -298,8 +277,7 @@ For string lookup, 'i' indicates case-in
idx = bin_lookup (table.data (), table.length (), argy,
std::ptr_fun (ov_str_comp));
- //retval(0) = idx;
- assign (retval(0), idx);
+ retval(0) = idx;
}
}
else
diff --git a/src/ov.cc b/src/ov.cc
--- a/src/ov.cc
+++ b/src/ov.cc
@@ -564,6 +564,15 @@ octave_value::octave_value (const ArrayN
octave_value::octave_value (const ArrayN<float>& a)
: rep (new octave_float_matrix (a))
{
+ maybe_mutate ();
+}
+
+octave_value::octave_value (const ArrayN<octave_idx_type>& a)
+{
+ NDArray tmp (a.dims ());
+ for (octave_idx_type i = 0; i < a.numel (); i++)
+ tmp(i) = a(i);
+ rep = new octave_matrix (tmp);
maybe_mutate ();
}
diff --git a/src/ov.h b/src/ov.h
--- a/src/ov.h
+++ b/src/ov.h
@@ -189,6 +189,7 @@ public:
octave_value (const FloatNDArray& nda);
octave_value (const ArrayN<double>& m);
octave_value (const ArrayN<float>& m);
+ octave_value (const ArrayN<octave_idx_type>& m);
octave_value (const DiagMatrix& d);
octave_value (const FloatDiagMatrix& d);
octave_value (const RowVector& v);