2 scalar.cc -- implement Scalar
4 source file of the Flower Library
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
12 #include "rational.hh"
15 Scalar::Scalar (Rational r)
20 Scalar::operator Rational ()
26 Scalar::to_rat () const
28 int p = index_i ('/');
32 String s2 = right_str (length_i ()-p-1);
33 String s1 = left_str (p);
35 return Rational (s1.value_i (), s2.value_i ());
39 Scalar::isdir_b () const
41 int conv = length_i ();
45 conv = sscanf (strh_.ch_C (), "%ld", &l);
46 conv = conv && (l >= -1 && l <= 1);
52 Scalar::isnum_b () const
58 conv = sscanf (strh_.ch_C (), "%ld", &l);
60 return length_i () && conv;
63 Scalar::operator Real()
75 Scalar::operator int ()
90 Scalar::operator bool () const
96 Scalar::to_bool () const
103 if (u.upper_str () == "FALSE")
108 Scalar::Scalar(Matrix const &m)
113 Scalar::Scalar (Vector const &v)