[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1 of 4] Add identity_val and conj_val functor objects to functor.
From: |
Jason Riedy |
Subject: |
[PATCH 1 of 4] Add identity_val and conj_val functor objects to functor.h |
Date: |
Mon, 09 Mar 2009 17:52:19 -0400 |
# HG changeset patch
# User Jason Riedy <address@hidden>
# Date 1236635352 14400
# Node ID 8ec69bd63c7360d9b186677968a5f93038c8c899
# Parent 42e24f4ebc8c70db07d0fcfd08d70b7a40e5519c
Add identity_val and conj_val functor objects to functor.h.
>From 059be213f0d43ff6f5874b689357119961b9dce7 Mon Sep 17 00:00:00 2001
Date: Sun, 8 Mar 2009 16:12:49 -0400
This is a stop-gap. Both of these are unnecessary given features in
the upcoming C++ revision, but wide implementation is some distance
off. Note that both are in an octave_impl namespace to avoid rampant
pollution. Namespaces are widely enough supported now.
Signed-off-by: Jason Riedy <address@hidden>
---
liboctave/ChangeLog | 12 ++++++++++++
liboctave/functor.h | 22 ++++++++++++++++++++++
2 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog
--- a/liboctave/ChangeLog
+++ b/liboctave/ChangeLog
@@ -1,3 +1,15 @@
+2009-03-08 Jason Riedy <address@hidden>
+
+ * functor.h (octave_impl::identity_val): New function object.
+ Takes a value and returns that value. Should eventually be
+ replaced by standard C++ functor, but those are in newer standards
+ versions.
+ (octave_impl::conj_val): New function object. Takes a value and
+ returns its conjugate. Imports std::conj rather than calling it
+ directly to allow non-standard types to pull in their own conj.
+ Again, this should be replaced by fancier functionality using
+ future C++ features eventually.
+
2009-03-08 Jaroslav Hajek <address@hidden>
* idx-vector.h (idx_vector::bloop): loop --> bloop.
diff --git a/liboctave/functor.h b/liboctave/functor.h
--- a/liboctave/functor.h
+++ b/liboctave/functor.h
@@ -72,6 +72,28 @@
return functor_with_conversion<CT, RT, PT> (f);
}
+namespace octave_impl {
+
+template <typename T>
+struct identity_val
+ : public std::unary_function <T, T>
+{
+ T operator () (const T x) { return x; }
+};
+
+template <typename T>
+struct conj_val
+ : public std::unary_function <T, T>
+{
+ T operator () (const T x)
+ {
+ using std::conj;
+ return conj (x);
+ }
+};
+
+} // namespace octave_impl
+
#endif
/*
- [PATCH 0 of 4] Implement basic sparse op diag and diag op sparse support., Jason Riedy, 2009/03/09
- [PATCH 1 of 4] Add identity_val and conj_val functor objects to functor.h,
Jason Riedy <=
- [PATCH 2 of 4] Implement sparse * diagonal and diagonal * sparse operations, double-prec only, Jason Riedy, 2009/03/09
- [PATCH 3 of 4] Implement diag \ sparse and sparse / diag, Jason Riedy, 2009/03/09
- [PATCH 4 of 4] Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag, Jason Riedy, 2009/03/09
- [PATCH 4 of 4] Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag, John W. Eaton, 2009/03/09
- Re: [PATCH 4 of 4] Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag, Jason Riedy, 2009/03/10
- Re: [PATCH 4 of 4] Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag, John W. Eaton, 2009/03/10
- Re: [PATCH 4 of 4] Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag, Jason Riedy, 2009/03/10
- Re: [PATCH 4 of 4] Implement diag + sparse, diag - sparse, sparse + diag, sparse - diag, Jaroslav Hajek, 2009/03/11
[PATCH 0 of 4] Implement basic sparse op diag and diag op sparse support., John W. Eaton, 2009/03/09