Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Commit [268a80] default Maximize Restore History

Trying to get basic implementation loadable

Pascal Dupuis Pascal Dupuis 2014-02-06

added src/mpv.cc
changed src/Makefile
copied src/ov-vpa.cc -> src/ov-mp.cc
copied src/ov-vpa.h -> src/ov-mp.h
copied src/op-vpa.cc -> src/op-mp.cc
src/mpv.cc Diff Switch to side-by-side view
Loading...
src/Makefile Diff Switch to side-by-side view
Loading...
src/ov-vpa.cc to src/ov-mp.cc
--- a/src/ov-vpa.cc
+++ b/src/ov-mp.cc
@@ -18,53 +18,65 @@
 */
 
 #include <octave/config.h>
-#include "ov-vpa.h"
+#include "ov-mp.h"
 
 // class ostream;
 
-octave_vpa::octave_vpa(void)
+octave_mp::octave_mp(void)
   :octave_base_value(), prec(mpfr_get_default_prec ()), rnd(mpfr_get_default_rounding_mode ())
 {
   mpfr_init_set_ui (scalar, 0, rnd);
 }
 
-octave_vpa::octave_vpa (signed long si)
+octave_mp::octave_mp (signed long si)
   :octave_base_value(), prec(mpfr_get_default_prec ()), rnd(mpfr_get_default_rounding_mode ())
 { 
   mpfr_init_set_si (scalar, si, rnd);
  }
 
-octave_vpa::octave_vpa (unsigned long ui)
+octave_mp::octave_mp (unsigned long ui)
   :octave_base_value(), prec(mpfr_get_default_prec ()), rnd(mpfr_get_default_rounding_mode ())
 { 
   mpfr_init_set_ui (scalar, ui, rnd);
  }
 
-octave_vpa::octave_vpa (const octave_vpa& s)
+octave_mp::octave_mp (const octave_mp& s)
   :octave_base_value(), prec(s.prec), rnd(s.rnd)
 { 
   mpfr_init_set(scalar, s.scalar, rnd);
 }
 
-octave_vpa::octave_vpa (const double& s, const mpfr_prec_t sprec)
+octave_mp::octave_mp (const double& s)
+  :octave_base_value(), prec(mpfr_get_default_prec ()), rnd(mpfr_get_default_rounding_mode ())
+{ 
+  mpfr_init_set_d(scalar, s, rnd);
+}
+
+octave_mp::octave_mp (const double& s, const mpfr_prec_t sprec)
   :octave_base_value(), prec(sprec), rnd(mpfr_get_default_rounding_mode ())
 { 
   mpfr_init_set_d(scalar, s, rnd);
 }
+
+octave_mp::octave_mp (const long double& s)
+  :octave_base_value(), prec(mpfr_get_default_prec ()), rnd(mpfr_get_default_rounding_mode ())
+{ 
+  mpfr_init_set_ld(scalar, s, rnd);
+}
  
-octave_vpa::octave_vpa (const long double& s, const mpfr_prec_t sprec)
+octave_mp::octave_mp (const long double& s, const mpfr_prec_t sprec)
   :octave_base_value(), prec(sprec), rnd(mpfr_get_default_rounding_mode ())
 { 
   mpfr_init_set_ld(scalar, s, rnd);
 } 
 
 void
-octave_vpa::print (std::ostream& os, bool pr_as_read_syntax) const
+octave_mp::print (std::ostream& os, bool pr_as_read_syntax) const
 {
   os << scalar;
 }
 
-DEFINE_OCTAVE_ALLOCATOR (octave_vpa);
+DEFINE_OCTAVE_ALLOCATOR (octave_mp);
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_vpa, "vpa", "multi-precision");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_mp, "mp", "multi-precision");
 
src/ov-vpa.h to src/ov-mp.h
--- a/src/ov-vpa.h
+++ b/src/ov-mp.h
@@ -16,8 +16,8 @@
 
 */
 
-#if !defined (octave_vpa_h)
-#define octave_vpa_h 1
+#if !defined (octave_mp_h)
+#define octave_mp_h 1
 
 // GNU MPFR and GMP
 #include <gmp.h>
@@ -26,23 +26,25 @@
 #include <octave/oct-alloc.h>
 #include <octave/ov-typeinfo.h>
 
-// vpa values.
+// mp values.
 
 class
-octave_vpa : public octave_base_value
+octave_mp : public octave_base_value
 {
 public:
 
-  octave_vpa (void);
-  octave_vpa (signed long si);
-  octave_vpa (unsigned long ui);
-  octave_vpa (const octave_vpa& s);
-  octave_vpa (const double& x, const mpfr_prec_t prec);
-  octave_vpa (const long double& x, const mpfr_prec_t prec);
+  octave_mp (void);
+  octave_mp (signed long si);
+  octave_mp (unsigned long ui);
+  octave_mp (const octave_mp& s);
+  octave_mp (const double& x);
+  octave_mp (const long double& x);
+  octave_mp (const double& x, const mpfr_prec_t prec);
+  octave_mp (const long double& x, const mpfr_prec_t prec);
 
-  ~octave_vpa (void) { mpfr_clear (scalar); }
+  ~octave_mp (void) { mpfr_clear (scalar); }
 
-  OV_REP_TYPE *clone (void) const { return new octave_vpa (*this); }
+  OV_REP_TYPE *clone (void) const { return new octave_mp (*this); }
 
 #if 0
   void *operator new (size_t size);
@@ -63,7 +65,7 @@
 
   bool is_real_type (void) const { return true; }
   bool is_scalar_type (void) const { return true; }
-  bool is_vpa_type (void) const { return true; }
+  bool is_mp_type (void) const { return true; }
 
   bool valid_as_scalar_index (void) const
   { 
@@ -82,7 +84,7 @@
 
   double double_value (bool = false) const { return mpfr_get_d(scalar, rnd); }
 
-  octave_value hermitian (void) const { return new octave_vpa (*this); }
+  octave_value hermitian (void) const { return new octave_mp (*this); }
 
   void increment (void) { mpfr_add_ui(scalar, scalar, 1, rnd); }
 
src/op-vpa.cc to src/op-mp.cc
--- a/src/op-vpa.cc
+++ b/src/op-mp.cc
@@ -23,57 +23,57 @@
 #include <octave/ov-re-mat.h>
 #include <octave/ov-cx-mat.h>
 #include <octave/oct-obj.h>
-#include "ov-vpa.h"
+#include "ov-mp.h"
 
-/* definitions for when vpa is first */
-// DEFINE_EX_MATRIX_OPS(vpa, ex_matrix)
-// DEFINE_EX_MATRIX_OPS(vpa, matrix)
-// DEFINE_EX_MATRIX_OPS(vpa, complex_matrix)
-// DEFINE_EX_EX_OPS(vpa, scalar)
-// DEFINE_EX_EX_OPS(vpa, complex)
-// DEFINE_EX_EX_OPS(vpa, vpa)
-// DEFINE_EX_EX_OPS(vpa, ex)
+/* definitions for when mp is first */
+// DEFINE_EX_MATRIX_OPS(mp, ex_matrix)
+// DEFINE_EX_MATRIX_OPS(mp, matrix)
+// DEFINE_EX_MATRIX_OPS(mp, complex_matrix)
+// DEFINE_EX_EX_OPS(mp, scalar)
+// DEFINE_EX_EX_OPS(mp, complex)
+// DEFINE_EX_EX_OPS(mp, mp)
+// DEFINE_EX_EX_OPS(mp, ex)
 
 /* extra operators need for octave builtin types */ 
-//DEFINE_MATRIX_EX_OPS(complex_matrix, vpa)
-//DEFINE_MATRIX_EX_OPS(matrix, vpa)
-//DEFINE_EX_EX_OPS(scalar, vpa)
-//DEFINE_EX_EX_OPS(complex, vpa)
+//DEFINE_MATRIX_EX_OPS(complex_matrix, mp)
+//DEFINE_MATRIX_EX_OPS(matrix, mp)
+//DEFINE_EX_EX_OPS(scalar, mp)
+//DEFINE_EX_EX_OPS(complex, mp)
 
-void install_vpa_ops()
+void install_mp_ops()
 {
-  // INSTALL_UNOP (op_not, octave_vpa, not);
+  // INSTALL_UNOP (op_not, octave_mp, not);
   /*
-  INSTALL_UNOP (op_uminus, octave_vpa, uminus);
-  INSTALL_UNOP (op_transpose, octave_vpa, transpose);
-  INSTALL_UNOP (op_hermitian, octave_vpa, hermitian);
+  INSTALL_UNOP (op_uminus, octave_mp, uminus);
+  INSTALL_UNOP (op_transpose, octave_mp, transpose);
+  INSTALL_UNOP (op_hermitian, octave_mp, hermitian);
   
-  INSTALL_NCUNOP (op_incr, octave_vpa, incr);
-  INSTALL_NCUNOP (op_decr, octave_vpa, decr);
+  INSTALL_NCUNOP (op_incr, octave_mp, incr);
+  INSTALL_NCUNOP (op_decr, octave_mp, decr);
   */
 
-  /* for when the vpa is first */
-  // INSTALL_EX_MATRIX_OPS(vpa, ex_matrix);
-  INSTALL_EX_MATRIX_OPS(vpa, matrix);
-  INSTALL_EX_MATRIX_OPS(vpa, complex_matrix);
-  INSTALL_EX_EX_OPS(vpa, scalar);
-  INSTALL_EX_EX_OPS(vpa, complex);
-  INSTALL_EX_EX_OPS(vpa, vpa);
-  //INSTALL_EX_EX_OPS(vpa, ex);
+  /* for when the mp is first */
+  // INSTALL_EX_MATRIX_OPS(mp, ex_matrix);
+  // INSTALL_EX_MATRIX_OPS(mp, matrix);
+  // INSTALL_EX_MATRIX_OPS(mp, complex_matrix);
+  // INSTALL_EX_EX_OPS(mp, scalar);
+  // INSTALL_EX_EX_OPS(mp, complex);
+  // INSTALL_EX_EX_OPS(mp, mp);
+  // INSTALL_EX_EX_OPS(mp, ex);
 
   /* extra operators need for octave builtin types */ 
-  INSTALL_MATRIX_EX_OPS(complex_matrix, vpa);
-  INSTALL_MATRIX_EX_OPS(matrix, vpa);
-  INSTALL_EX_EX_OPS(scalar, vpa);
-  INSTALL_EX_EX_OPS(complex, vpa);
+  // INSTALL_MATRIX_EX_OPS(complex_matrix, mp);
+  // INSTALL_MATRIX_EX_OPS(matrix, mp);
+  // INSTALL_EX_EX_OPS(scalar, mp);
+  // INSTALL_EX_EX_OPS(complex, mp);
 
 
   /* 
-  INSTALL_BINOP (op_lt, octave_vpa, octave_vpa, lt);
-  INSTALL_BINOP (op_le, octave_vpa, octave_vpa, le);
-  INSTALL_BINOP (op_eq, octave_vpa, octave_vpa, eq);
-  INSTALL_BINOP (op_ge, octave_vpa, octave_vpa, ge);
-  INSTALL_BINOP (op_gt, octave_vpa, octave_vpa, gt);
-  INSTALL_BINOP (op_ne, octave_vpa, octave_vpa, ne);
+  INSTALL_BINOP (op_lt, octave_mp, octave_mp, lt);
+  INSTALL_BINOP (op_le, octave_mp, octave_mp, le);
+  INSTALL_BINOP (op_eq, octave_mp, octave_mp, eq);
+  INSTALL_BINOP (op_ge, octave_mp, octave_mp, ge);
+  INSTALL_BINOP (op_gt, octave_mp, octave_mp, gt);
+  INSTALL_BINOP (op_ne, octave_mp, octave_mp, ne);
   */
 }