Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026
00027 #include <iostream>
00028
00029 #include "oct-obj.h"
00030 #include "ov-base.h"
00031 #include "ov-cx-mat.h"
00032 #include "ov-re-mat.h"
00033 #include "ov-base-scalar.h"
00034 #include "pr-output.h"
00035
00036 template <class ST>
00037 octave_value
00038 octave_base_scalar<ST>::subsref (const std::string& type,
00039 const std::list<octave_value_list>& idx)
00040 {
00041 octave_value retval;
00042
00043 switch (type[0])
00044 {
00045 case '(':
00046 retval = do_index_op (idx.front ());
00047 break;
00048
00049 case '{':
00050 case '.':
00051 {
00052 std::string nm = type_name ();
00053 error ("%s cannot be indexed with %c", nm.c_str (), type[0]);
00054 }
00055 break;
00056
00057 default:
00058 panic_impossible ();
00059 }
00060
00061 return retval.next_subsref (type, idx);
00062 }
00063
00064 template <class ST>
00065 octave_value
00066 octave_base_scalar<ST>::subsasgn (const std::string& type,
00067 const std::list<octave_value_list>& idx,
00068 const octave_value& rhs)
00069 {
00070 octave_value retval;
00071
00072 switch (type[0])
00073 {
00074 case '(':
00075 {
00076 if (type.length () == 1)
00077 retval = numeric_assign (type, idx, rhs);
00078 else
00079 {
00080 std::string nm = type_name ();
00081 error ("in indexed assignment of %s, last rhs index must be ()",
00082 nm.c_str ());
00083 }
00084 }
00085 break;
00086
00087 case '{':
00088 case '.':
00089 {
00090 std::string nm = type_name ();
00091 error ("%s cannot be indexed with %c", nm.c_str (), type[0]);
00092 }
00093 break;
00094
00095 default:
00096 panic_impossible ();
00097 }
00098
00099 return retval;
00100 }
00101
00102 template <class ST>
00103 octave_value
00104 octave_base_scalar<ST>::permute (const Array<int>& vec, bool inv) const
00105 {
00106 return Array<ST> (dim_vector (1, 1), scalar).permute (vec, inv);
00107 }
00108
00109 template <class ST>
00110 octave_value
00111 octave_base_scalar<ST>::reshape (const dim_vector& new_dims) const
00112 {
00113 return Array<ST> (dim_vector (1, 1), scalar).reshape (new_dims);
00114 }
00115
00116 template <class ST>
00117 octave_value
00118 octave_base_scalar<ST>::diag (octave_idx_type k) const
00119 {
00120 return Array<ST> (dim_vector (1, 1), scalar).diag (k);
00121 }
00122
00123 template <class ST>
00124 bool
00125 octave_base_scalar<ST>::is_true (void) const
00126 {
00127 bool retval = false;
00128
00129 if (xisnan (scalar))
00130 gripe_nan_to_logical_conversion ();
00131 else
00132 retval = (scalar != ST ());
00133
00134 return retval;
00135 }
00136
00137 template <class ST>
00138 void
00139 octave_base_scalar<ST>::print (std::ostream& os, bool pr_as_read_syntax) const
00140 {
00141 print_raw (os, pr_as_read_syntax);
00142 newline (os);
00143 }
00144
00145 template <class ST>
00146 void
00147 octave_base_scalar<ST>::print_raw (std::ostream& os,
00148 bool pr_as_read_syntax) const
00149 {
00150 indent (os);
00151 octave_print_internal (os, scalar, pr_as_read_syntax);
00152 }
00153
00154 template <class ST>
00155 bool
00156 octave_base_scalar<ST>::print_name_tag (std::ostream& os,
00157 const std::string& name) const
00158 {
00159 indent (os);
00160 os << name << " = ";
00161 return false;
00162 }
00163
00164 template <class ST>
00165 bool
00166 octave_base_scalar<ST>::fast_elem_insert_self (void *where, builtin_type_t btyp) const
00167 {
00168
00169
00170 if (btyp == class_to_btyp<ST>::btyp)
00171 {
00172 *(reinterpret_cast<ST *>(where)) = scalar;
00173 return true;
00174 }
00175 else
00176 return false;
00177 }