コード例 #1
0
boolean JRealComplexObj::setLabel(JString _label) { 
  if (setCValue((jcomplex)JComplex(_label))) return true;
  _label = JComplex::toJStringF(cval, w, f);
  if (_label != label) {
    label = _label;
    broadcast(OUT_STRING);
    repaint();
    return true;
  }
  return false;
}
コード例 #2
0
JBoolean
JTruncateToInt::Evaluate
	(
	JComplex* result
	)
	const
{
	JComplex value;
	if (!(GetArg())->Evaluate(&value))
		{
		return kJFalse;
		}
	jclear_errno();
	*result = JComplex(JTruncate(real(value)), JTruncate(imag(value)));
	return jerrno_is_clear();
}
コード例 #3
0
JBoolean
JNamedConstant::Evaluate
	(
	JComplex* result
	)
	const
{
	if (itsNameIndex == kIJNamedConstIndex)		// i is not a real number
		{
		*result = JComplex(0.0, 1.0);
		}
	else
		{
		*result = kNamedConstValues[ itsNameIndex-1 ];
		}

	return kJTrue;
}
コード例 #4
0
void JRealComplexObj::engine(int n, JLinkObj& link) {
  switch (n) {
    case IN_DATA: {
      jcomplex iv = cval;
      link.access(JComplexData(iv));
      setCValue(iv);
      break;
    }
    case IN_STRING: {
	  JString iv = JComplex::toJString(cval);
      link.access(JStringData(iv));
      setCValue((jcomplex)JComplex(iv));
      break;
    }
    default:
      JLabelObj::engine(n, link);
  }
}
コード例 #5
0
ファイル: JComplex.cpp プロジェクト: neattools/neattools
#include "JBlock.h"
#include "JMath.h"
#include <stdlib.h>
#include <stdio.h>
#include "JComplex.h"
#include "JDouble.h"

char* theJComplex = JComplex().Register();

void JComplex::writeContent(JOutputStream& os) {
  JObject::writeContent(os);
  putDouble(os, "real", value.r);
  putDouble(os, "imag", value.i);
}

void JComplex::readContent(JDictionary& dict) {
  JObject::readContent(dict);
  value.r = getDouble(dict, "real");
  value.i = getDouble(dict, "image");
}

JString JComplex::toJString(const jcomplex& c) { 
  JBlock buf(50, 0);
  sprintf(buf, "%.10lg,%.10lgi", c.r, c.i);
  return JString(buf);
}

JString JComplex::toJStringF(const jcomplex& c, int w, int f) { 
  if (w <= 0) return toJString(c);
  JBlock buf(50, 0), format(50, 0);
  sprintf(format, "%%%d.%dlf,%%%d.%dlfi", w, f, w, f);