Add lots more trig and log functions and some stack functions

This commit is contained in:
Jeremy Rand 2013-07-27 00:04:01 -05:00
parent 9f2f1c5d53
commit c470afc9d6
50 changed files with 1508 additions and 5 deletions

View File

@ -12,7 +12,12 @@ OPS_OBJS=ops/abCOp.o ops/abCOpAdd.o ops/abCOpSubtr.o ops/abCOpMult.o \
ops/abCOpDiv.o ops/abCOpPower.o ops/abCOpAnd.o ops/abCOpOr.o ops/abCOpXor.o \
ops/abCOpNot.o ops/abCOpBin.o ops/abCOpOct.o ops/abCOpDec.o ops/abCOpHex.o \
ops/abCOpStws.o ops/abCOpRcws.o ops/abCOpSl.o ops/abCOpRl.o ops/abCOpSr.o \
ops/abCOpRr.o ops/abCOpAsr.o ops/abCOpInv.o ops/abCOpChs.o ops/abCOpDrop.o
ops/abCOpRr.o ops/abCOpAsr.o ops/abCOpInv.o ops/abCOpChs.o ops/abCOpDrop.o \
ops/abCOpSwap.o ops/abCOpSin.o ops/abCOpCos.o ops/abCOpTan.o ops/abCOpAsin.o \
ops/abCOpAcos.o ops/abCOpAtan.o ops/abCOpSq.o ops/abCOpSqrt.o ops/abCOpPi.o \
ops/abCOpLog.o ops/abCOpAlog.o ops/abCOpLn.o ops/abCOpExp.o ops/abCOpLnp1.o \
ops/abCOpExpm.o ops/abCOpSinh.o ops/abCOpAsinh.o ops/abCOpCosh.o \
ops/abCOpAcosh.o ops/abCOpTanh.o ops/abCOpAtanh.o ops/abCOpClear.o
SHELL_OBJS=abCMain.o $(CALC_OBJS) $(EXPR_OBJS) $(OPS_OBJS)
@ -61,4 +66,27 @@ ops/abCOpAsr.o: ops/abCOp.h abCMode.h abCError.h abCStack.h expr/abCExpr.h expr/
ops/abCOpInv.o: ops/abCOp.h abCError.h abCStack.h expr/abCExpr.h expr/abCExpReal.h ops/abCOpInv.h
ops/abCOpChs.o: ops/abCOp.h abCError.h abCStack.h expr/abCExpr.h expr/abCExpReal.h ops/abCOpChs.h
ops/abCOpDrop.o: ops/abCOp.h abCError.h abCStack.h expr/abCExpr.h ops/abCOpDrop.h
ops/abCOpSwap.o: ops/abCOp.h abCError.h abCStack.h expr/abCExpr.h ops/abCOpSwap.h
ops/abCOpSin.o: ops/abCOp.h abCError.h abCStack.h expr/abCExpr.h expr/abCExpReal.h ops/abCOpSin.h
ops/abCOpCos.o: ops/abCOp.h abCError.h abCStack.h expr/abCExpr.h expr/abCExpReal.h ops/abCOpCos.h
ops/abCOpTan.o: ops/abCOp.h abCError.h abCStack.h expr/abCExpr.h expr/abCExpReal.h ops/abCOpTan.h
ops/abCOpAsin.o: ops/abCOp.h abCError.h abCStack.h expr/abCExpr.h expr/abCExpReal.h ops/abCOpAsin.h
ops/abCOpAcos.o: ops/abCOp.h abCError.h abCStack.h expr/abCExpr.h expr/abCExpReal.h ops/abCOpAcos.h
ops/abCOpAtan.o: ops/abCOp.h abCError.h abCStack.h expr/abCExpr.h expr/abCExpReal.h ops/abCOpAtan.h
ops/abCOpSq.o: ops/abCOp.h abCError.h abCStack.h expr/abCExpr.h expr/abCExpReal.h ops/abCOpSq.h
ops/abCOpSqrt.o: ops/abCOp.h abCError.h abCStack.h expr/abCExpr.h expr/abCExpReal.h ops/abCOpSqrt.h
ops/abCOpPi.o: ops/abCOp.h abCStack.h expr/abCExpr.h expr/abCExpReal.h ops/abCOpPi.h
ops/abCOpLog.o: ops/abCOp.h abCError.h abCStack.h expr/abCExpr.h expr/abCExpReal.h ops/abCOpLog.h
ops/abCOpAlog.o: ops/abCOp.h abCError.h abCStack.h expr/abCExpr.h expr/abCExpReal.h ops/abCOpAlog.h
ops/abCOpLn.o: ops/abCOp.h abCError.h abCStack.h expr/abCExpr.h expr/abCExpReal.h ops/abCOpLn.h
ops/abCOpExp.o: ops/abCOp.h abCError.h abCStack.h expr/abCExpr.h expr/abCExpReal.h ops/abCOpExp.h
ops/abCOpLnp1.o: ops/abCOp.h abCError.h abCStack.h expr/abCExpr.h expr/abCExpReal.h ops/abCOpLnp1.h
ops/abCOpExpm.o: ops/abCOp.h abCError.h abCStack.h expr/abCExpr.h expr/abCExpReal.h ops/abCOpExpm.h
ops/abCOpSinh.o: ops/abCOp.h abCError.h abCStack.h expr/abCExpr.h expr/abCExpReal.h ops/abCOpSinh.h
ops/abCOpAsinh.o: ops/abCOp.h abCError.h abCStack.h expr/abCExpr.h expr/abCExpReal.h ops/abCOpAsinh.h
ops/abCOpCosh.o: ops/abCOp.h abCError.h abCStack.h expr/abCExpr.h expr/abCExpReal.h ops/abCOpCosh.h
ops/abCOpAcosh.o: ops/abCOp.h abCError.h abCStack.h expr/abCExpr.h expr/abCExpReal.h ops/abCOpAcosh.h
ops/abCOpTanh.o: ops/abCOp.h abCError.h abCStack.h expr/abCExpr.h expr/abCExpReal.h ops/abCOpTanh.h
ops/abCOpAtanh.o: ops/abCOp.h abCError.h abCStack.h expr/abCExpr.h expr/abCExpReal.h ops/abCOpAtanh.h
ops/abCOpClear.o: ops/abCOp.h abCStack.h ops/abCOpClear.h

View File

@ -91,3 +91,9 @@ char *abCalcStackExprStringAt(int depth, char *buffer)
return buffer;
}
void abCalcStackClear(void)
{
gStackNumItems = 0;
}

View File

@ -26,5 +26,7 @@ char *abCalcStackExprStringAt(int depth, char *buffer);
int abCalcStackNumItems(void);
void abCalcStackClear(void);
#endif

View File

@ -19,9 +19,36 @@
#include "ops/abCOpSubtr.h"
#include "ops/abCOpMult.h"
#include "ops/abCOpDiv.h"
#include "ops/abCOpPower.h"
#include "ops/abCOpInv.h"
#include "ops/abCOpChs.h"
#include "ops/abCOpInv.h"
#include "ops/abCOpSq.h"
#include "ops/abCOpSqrt.h"
#include "ops/abCOpPower.h"
#include "ops/abCOpDrop.h"
#include "ops/abCOpSwap.h"
#include "ops/abCOpClear.h"
#include "ops/abCOpPi.h"
#include "ops/abCOpSin.h"
#include "ops/abCOpCos.h"
#include "ops/abCOpTan.h"
#include "ops/abCOpAsin.h"
#include "ops/abCOpAcos.h"
#include "ops/abCOpAtan.h"
#include "ops/abCOpLog.h"
#include "ops/abCOpAlog.h"
#include "ops/abCOpLn.h"
#include "ops/abCOpExp.h"
#include "ops/abCOpLnp1.h"
#include "ops/abCOpExpm.h"
#include "ops/abCOpSinh.h"
#include "ops/abCOpAsinh.h"
#include "ops/abCOpCosh.h"
#include "ops/abCOpAcosh.h"
#include "ops/abCOpTanh.h"
#include "ops/abCOpAtanh.h"
#include "ops/abCOpAnd.h"
#include "ops/abCOpOr.h"
@ -56,11 +83,36 @@ void abCalcOpInit(void)
abCalcOpSubtrInit();
abCalcOpMultInit();
abCalcOpDivInit();
abCalcOpPowerInit();
abCalcOpInvInit();
abCalcOpChsInit();
abCalcOpInvInit();
abCalcOpSqInit();
abCalcOpSqrtInit();
abCalcOpPowerInit();
abCalcOpDropInit();
abCalcOpSwapInit();
abCalcOpClearInit();
abCalcOpPiInit();
abCalcOpSinInit();
abCalcOpCosInit();
abCalcOpTanInit();
abCalcOpAsinInit();
abCalcOpAcosInit();
abCalcOpAtanInit();
abCalcOpLogInit();
abCalcOpAlogInit();
abCalcOpLnInit();
abCalcOpExpInit();
abCalcOpLnp1Init();
abCalcOpExpmInit();
abCalcOpSinhInit();
abCalcOpAsinhInit();
abCalcOpCoshInit();
abCalcOpAcoshInit();
abCalcOpTanhInit();
abCalcOpAtanhInit();
abCalcOpAndInit();
abCalcOpOrInit();

52
ops/abCOpAcos.c Normal file
View File

@ -0,0 +1,52 @@
/*
abCOpAcos.c
By: Jeremy Rand
*/
#include <math.h>
#include <stdio.h>
#include "abCError.h"
#include "abCStack.h"
#include "expr/abCExpr.h"
#include "expr/abCExpReal.h"
#include "ops/abCOp.h"
#include "ops/abCOpAcos.h"
#define ACOS_NAME "ACOS"
static void acosExecute(void);
void abCalcOpAcosInit(void)
{
abCalcOpRegister(ACOS_NAME, acosExecute);
}
void acosExecute(void)
{
abCalcExpr result;
AB_CALC_OP_ONE_ARG(ACOS_NAME);
if (expr->type != abCalcExprTypeReal) {
abCalcRaiseError(abCalcBadArgTypeError, ACOS_NAME);
return;
}
if ((expr->u.real < -1.0) ||
(expr->u.real > 1.0)) {
abCalcRaiseError(abCalcComplexResultError, ACOS_NAME);
return;
}
abCalcExprRealSet(&result, acos(expr->u.real));
abCalcStackExprPop(NULL);
abCalcStackExprPush(&result);
}

14
ops/abCOpAcos.h Normal file
View File

@ -0,0 +1,14 @@
/*
abCOpAcos.h
By: Jeremy Rand
*/
#ifndef ABCOPACOS_H
#define ABCOPACOS_H
void abCalcOpAcosInit(void);
#endif

51
ops/abCOpAcosh.c Normal file
View File

@ -0,0 +1,51 @@
/*
abCOpAcosh.c
By: Jeremy Rand
*/
#include <math.h>
#include <stdio.h>
#include "abCError.h"
#include "abCStack.h"
#include "expr/abCExpr.h"
#include "expr/abCExpReal.h"
#include "ops/abCOp.h"
#include "ops/abCOpAcosh.h"
#define ACOSH_NAME "ACOSH"
static void acoshExecute(void);
void abCalcOpAcoshInit(void)
{
abCalcOpRegister(ACOSH_NAME, acoshExecute);
}
void acoshExecute(void)
{
abCalcExpr result;
AB_CALC_OP_ONE_ARG(ACOSH_NAME);
if (expr->type != abCalcExprTypeReal) {
abCalcRaiseError(abCalcBadArgTypeError, ACOSH_NAME);
return;
}
if (expr->u.real < 1.0) {
abCalcRaiseError(abCalcComplexResultError, ACOSH_NAME);
return;
}
abCalcExprRealSet(&result, acosh(expr->u.real));
abCalcStackExprPop(NULL);
abCalcStackExprPush(&result);
}

14
ops/abCOpAcosh.h Normal file
View File

@ -0,0 +1,14 @@
/*
abCOpAcosh.h
By: Jeremy Rand
*/
#ifndef ABCOPACOSH_H
#define ABCOPACOSH_H
void abCalcOpAcoshInit(void);
#endif

46
ops/abCOpAlog.c Normal file
View File

@ -0,0 +1,46 @@
/*
abCOpAlog.c
By: Jeremy Rand
*/
#include <math.h>
#include <stdio.h>
#include "abCError.h"
#include "abCStack.h"
#include "expr/abCExpr.h"
#include "expr/abCExpReal.h"
#include "ops/abCOp.h"
#include "ops/abCOpAlog.h"
#define ALOG_NAME "ALOG"
static void alogExecute(void);
void abCalcOpAlogInit(void)
{
abCalcOpRegister(ALOG_NAME, alogExecute);
}
void alogExecute(void)
{
abCalcExpr result;
AB_CALC_OP_ONE_ARG(ALOG_NAME);
if (expr->type != abCalcExprTypeReal) {
abCalcRaiseError(abCalcBadArgTypeError, ALOG_NAME);
return;
}
abCalcExprRealSet(&result, pow(10.0, expr->u.real));
abCalcStackExprPop(NULL);
abCalcStackExprPush(&result);
}

14
ops/abCOpAlog.h Normal file
View File

@ -0,0 +1,14 @@
/*
abCOpAlog.h
By: Jeremy Rand
*/
#ifndef ABCOPALOG_H
#define ABCOPALOG_H
void abCalcOpAlogInit(void);
#endif

52
ops/abCOpAsin.c Normal file
View File

@ -0,0 +1,52 @@
/*
abCOpAsin.c
By: Jeremy Rand
*/
#include <math.h>
#include <stdio.h>
#include "abCError.h"
#include "abCStack.h"
#include "expr/abCExpr.h"
#include "expr/abCExpReal.h"
#include "ops/abCOp.h"
#include "ops/abCOpAsin.h"
#define ASIN_NAME "ASIN"
static void asinExecute(void);
void abCalcOpAsinInit(void)
{
abCalcOpRegister(ASIN_NAME, asinExecute);
}
void asinExecute(void)
{
abCalcExpr result;
AB_CALC_OP_ONE_ARG(ASIN_NAME);
if (expr->type != abCalcExprTypeReal) {
abCalcRaiseError(abCalcBadArgTypeError, ASIN_NAME);
return;
}
if ((expr->u.real < -1.0) ||
(expr->u.real > 1.0)) {
abCalcRaiseError(abCalcComplexResultError, ASIN_NAME);
return;
}
abCalcExprRealSet(&result, asin(expr->u.real));
abCalcStackExprPop(NULL);
abCalcStackExprPush(&result);
}

14
ops/abCOpAsin.h Normal file
View File

@ -0,0 +1,14 @@
/*
abCOpAsin.h
By: Jeremy Rand
*/
#ifndef ABCOPASIN_H
#define ABCOPASIN_H
void abCalcOpAsinInit(void);
#endif

46
ops/abCOpAsinh.c Normal file
View File

@ -0,0 +1,46 @@
/*
abCOpAsinh.c
By: Jeremy Rand
*/
#include <math.h>
#include <stdio.h>
#include "abCError.h"
#include "abCStack.h"
#include "expr/abCExpr.h"
#include "expr/abCExpReal.h"
#include "ops/abCOp.h"
#include "ops/abCOpAsinh.h"
#define ASINH_NAME "ASINH"
static void asinhExecute(void);
void abCalcOpAsinhInit(void)
{
abCalcOpRegister(ASINH_NAME, asinhExecute);
}
void asinhExecute(void)
{
abCalcExpr result;
AB_CALC_OP_ONE_ARG(ASINH_NAME);
if (expr->type != abCalcExprTypeReal) {
abCalcRaiseError(abCalcBadArgTypeError, ASINH_NAME);
return;
}
abCalcExprRealSet(&result, asinh(expr->u.real));
abCalcStackExprPop(NULL);
abCalcStackExprPush(&result);
}

14
ops/abCOpAsinh.h Normal file
View File

@ -0,0 +1,14 @@
/*
abCOpAsinh.h
By: Jeremy Rand
*/
#ifndef ABCOPASINH_H
#define ABCOPASINH_H
void abCalcOpAsinhInit(void);
#endif

46
ops/abCOpAtan.c Normal file
View File

@ -0,0 +1,46 @@
/*
abCOpAtan.c
By: Jeremy Rand
*/
#include <math.h>
#include <stdio.h>
#include "abCError.h"
#include "abCStack.h"
#include "expr/abCExpr.h"
#include "expr/abCExpReal.h"
#include "ops/abCOp.h"
#include "ops/abCOpAtan.h"
#define ATAN_NAME "ATAN"
static void atanExecute(void);
void abCalcOpAtanInit(void)
{
abCalcOpRegister(ATAN_NAME, atanExecute);
}
void atanExecute(void)
{
abCalcExpr result;
AB_CALC_OP_ONE_ARG(ATAN_NAME);
if (expr->type != abCalcExprTypeReal) {
abCalcRaiseError(abCalcBadArgTypeError, ATAN_NAME);
return;
}
abCalcExprRealSet(&result, atan(expr->u.real));
abCalcStackExprPop(NULL);
abCalcStackExprPush(&result);
}

14
ops/abCOpAtan.h Normal file
View File

@ -0,0 +1,14 @@
/*
abCOpAtan.h
By: Jeremy Rand
*/
#ifndef ABCOPATAN_H
#define ABCOPATAN_H
void abCalcOpAtanInit(void);
#endif

57
ops/abCOpAtanh.c Normal file
View File

@ -0,0 +1,57 @@
/*
abCOpAtanh.c
By: Jeremy Rand
*/
#include <math.h>
#include <stdio.h>
#include "abCError.h"
#include "abCStack.h"
#include "expr/abCExpr.h"
#include "expr/abCExpReal.h"
#include "ops/abCOp.h"
#include "ops/abCOpAtanh.h"
#define ATANH_NAME "ATANH"
static void atanhExecute(void);
void abCalcOpAtanhInit(void)
{
abCalcOpRegister(ATANH_NAME, atanhExecute);
}
void atanhExecute(void)
{
abCalcExpr result;
AB_CALC_OP_ONE_ARG(ATANH_NAME);
if (expr->type != abCalcExprTypeReal) {
abCalcRaiseError(abCalcBadArgTypeError, ATANH_NAME);
return;
}
if ((expr->u.real == 1.0) ||
(expr->u.real == -1.0)) {
abCalcRaiseError(abCalcInfiniteResultError, ATANH_NAME);
return;
}
if ((expr->u.real > 1.0) ||
(expr->u.real < -1.0)) {
abCalcRaiseError(abCalcComplexResultError, ATANH_NAME);
return;
}
abCalcExprRealSet(&result, atanh(expr->u.real));
abCalcStackExprPop(NULL);
abCalcStackExprPush(&result);
}

14
ops/abCOpAtanh.h Normal file
View File

@ -0,0 +1,14 @@
/*
abCOpAtanh.h
By: Jeremy Rand
*/
#ifndef ABCOPATANH_H
#define ABCOPATANH_H
void abCalcOpAtanhInit(void);
#endif

31
ops/abCOpClear.c Normal file
View File

@ -0,0 +1,31 @@
/*
abCOpClear.c
By: Jeremy Rand
*/
#include <math.h>
#include <stdio.h>
#include "abCStack.h"
#include "ops/abCOp.h"
#include "ops/abCOpClear.h"
#define CLEAR_NAME "CLEAR"
static void clearExecute(void);
void abCalcOpClearInit(void)
{
abCalcOpRegister(CLEAR_NAME, clearExecute);
}
void clearExecute(void)
{
abCalcStackClear();
}

14
ops/abCOpClear.h Normal file
View File

@ -0,0 +1,14 @@
/*
abCOpClean.h
By: Jeremy Rand
*/
#ifndef ABCOPCLEAR_H
#define ABCOPCLEAR_H
void abCalcOpClearInit(void);
#endif

46
ops/abCOpCos.c Normal file
View File

@ -0,0 +1,46 @@
/*
abCOpCos.c
By: Jeremy Rand
*/
#include <math.h>
#include <stdio.h>
#include "abCError.h"
#include "abCStack.h"
#include "expr/abCExpr.h"
#include "expr/abCExpReal.h"
#include "ops/abCOp.h"
#include "ops/abCOpCos.h"
#define COS_NAME "COS"
static void cosExecute(void);
void abCalcOpCosInit(void)
{
abCalcOpRegister(COS_NAME, cosExecute);
}
void cosExecute(void)
{
abCalcExpr result;
AB_CALC_OP_ONE_ARG(COS_NAME);
if (expr->type != abCalcExprTypeReal) {
abCalcRaiseError(abCalcBadArgTypeError, COS_NAME);
return;
}
abCalcExprRealSet(&result, cos(expr->u.real));
abCalcStackExprPop(NULL);
abCalcStackExprPush(&result);
}

14
ops/abCOpCos.h Normal file
View File

@ -0,0 +1,14 @@
/*
abCOpCos.h
By: Jeremy Rand
*/
#ifndef ABCOPCOS_H
#define ABCOPCOS_H
void abCalcOpCosInit(void);
#endif

46
ops/abCOpCosh.c Normal file
View File

@ -0,0 +1,46 @@
/*
abCOpCosh.c
By: Jeremy Rand
*/
#include <math.h>
#include <stdio.h>
#include "abCError.h"
#include "abCStack.h"
#include "expr/abCExpr.h"
#include "expr/abCExpReal.h"
#include "ops/abCOp.h"
#include "ops/abCOpCosh.h"
#define COSH_NAME "COSH"
static void coshExecute(void);
void abCalcOpCoshInit(void)
{
abCalcOpRegister(COSH_NAME, coshExecute);
}
void coshExecute(void)
{
abCalcExpr result;
AB_CALC_OP_ONE_ARG(COSH_NAME);
if (expr->type != abCalcExprTypeReal) {
abCalcRaiseError(abCalcBadArgTypeError, COSH_NAME);
return;
}
abCalcExprRealSet(&result, cosh(expr->u.real));
abCalcStackExprPop(NULL);
abCalcStackExprPush(&result);
}

14
ops/abCOpCosh.h Normal file
View File

@ -0,0 +1,14 @@
/*
abCOpCosh.h
By: Jeremy Rand
*/
#ifndef ABCOPCOSH_H
#define ABCOPCOSH_H
void abCalcOpCoshInit(void);
#endif

46
ops/abCOpExp.c Normal file
View File

@ -0,0 +1,46 @@
/*
abCOpExp.c
By: Jeremy Rand
*/
#include <math.h>
#include <stdio.h>
#include "abCError.h"
#include "abCStack.h"
#include "expr/abCExpr.h"
#include "expr/abCExpReal.h"
#include "ops/abCOp.h"
#include "ops/abCOpExp.h"
#define EXP_NAME "EXP"
static void expExecute(void);
void abCalcOpExpInit(void)
{
abCalcOpRegister(EXP_NAME, expExecute);
}
void expExecute(void)
{
abCalcExpr result;
AB_CALC_OP_ONE_ARG(EXP_NAME);
if (expr->type != abCalcExprTypeReal) {
abCalcRaiseError(abCalcBadArgTypeError, EXP_NAME);
return;
}
abCalcExprRealSet(&result, exp(expr->u.real));
abCalcStackExprPop(NULL);
abCalcStackExprPush(&result);
}

14
ops/abCOpExp.h Normal file
View File

@ -0,0 +1,14 @@
/*
abCOpExp.h
By: Jeremy Rand
*/
#ifndef ABCOPEXP_H
#define ABCOPEXP_H
void abCalcOpExpInit(void);
#endif

46
ops/abCOpExpm.c Normal file
View File

@ -0,0 +1,46 @@
/*
abCOpExpm.c
By: Jeremy Rand
*/
#include <math.h>
#include <stdio.h>
#include "abCError.h"
#include "abCStack.h"
#include "expr/abCExpr.h"
#include "expr/abCExpReal.h"
#include "ops/abCOp.h"
#include "ops/abCOpExpm.h"
#define EXPM_NAME "EXPM"
static void expmExecute(void);
void abCalcOpExpmInit(void)
{
abCalcOpRegister(EXPM_NAME, expmExecute);
}
void expmExecute(void)
{
abCalcExpr result;
AB_CALC_OP_ONE_ARG(EXPM_NAME);
if (expr->type != abCalcExprTypeReal) {
abCalcRaiseError(abCalcBadArgTypeError, EXPM_NAME);
return;
}
abCalcExprRealSet(&result, expm1(expr->u.real));
abCalcStackExprPop(NULL);
abCalcStackExprPush(&result);
}

14
ops/abCOpExpm.h Normal file
View File

@ -0,0 +1,14 @@
/*
abCOpExpm.h
By: Jeremy Rand
*/
#ifndef ABCOPEXPM_H
#define ABCOPEXPM_H
void abCalcOpExpmInit(void);
#endif

55
ops/abCOpLn.c Normal file
View File

@ -0,0 +1,55 @@
/*
abCOpLn.c
By: Jeremy Rand
*/
#include <math.h>
#include <stdio.h>
#include "abCError.h"
#include "abCStack.h"
#include "expr/abCExpr.h"
#include "expr/abCExpReal.h"
#include "ops/abCOp.h"
#include "ops/abCOpLn.h"
#define LN_NAME "LN"
static void lnExecute(void);
void abCalcOpLnInit(void)
{
abCalcOpRegister(LN_NAME, lnExecute);
}
void lnExecute(void)
{
abCalcExpr result;
AB_CALC_OP_ONE_ARG(LN_NAME);
if (expr->type != abCalcExprTypeReal) {
abCalcRaiseError(abCalcBadArgTypeError, LN_NAME);
return;
}
if (expr->u.real == 0.0) {
abCalcRaiseError(abCalcInfiniteResultError, LN_NAME);
return;
}
if (expr->u.real < 0.0) {
abCalcRaiseError(abCalcComplexResultError, LN_NAME);
return;
}
abCalcExprRealSet(&result, log(expr->u.real));
abCalcStackExprPop(NULL);
abCalcStackExprPush(&result);
}

14
ops/abCOpLn.h Normal file
View File

@ -0,0 +1,14 @@
/*
abCOpLn.h
By: Jeremy Rand
*/
#ifndef ABCOPLN_H
#define ABCOPLN_H
void abCalcOpLnInit(void);
#endif

55
ops/abCOpLnp1.c Normal file
View File

@ -0,0 +1,55 @@
/*
abCOpLnp1.c
By: Jeremy Rand
*/
#include <math.h>
#include <stdio.h>
#include "abCError.h"
#include "abCStack.h"
#include "expr/abCExpr.h"
#include "expr/abCExpReal.h"
#include "ops/abCOp.h"
#include "ops/abCOpLnp1.h"
#define LNP1_NAME "LNP1"
static void lnp1Execute(void);
void abCalcOpLnp1Init(void)
{
abCalcOpRegister(LNP1_NAME, lnp1Execute);
}
void lnp1Execute(void)
{
abCalcExpr result;
AB_CALC_OP_ONE_ARG(LNP1_NAME);
if (expr->type != abCalcExprTypeReal) {
abCalcRaiseError(abCalcBadArgTypeError, LNP1_NAME);
return;
}
if (expr->u.real == -1.0) {
abCalcRaiseError(abCalcInfiniteResultError, LNP1_NAME);
return;
}
if (expr->u.real < -1.0) {
abCalcRaiseError(abCalcComplexResultError, LNP1_NAME);
return;
}
abCalcExprRealSet(&result, log1p(expr->u.real));
abCalcStackExprPop(NULL);
abCalcStackExprPush(&result);
}

14
ops/abCOpLnp1.h Normal file
View File

@ -0,0 +1,14 @@
/*
abCOpLnp1.h
By: Jeremy Rand
*/
#ifndef ABCOPLNP1_H
#define ABCOPLNP1_H
void abCalcOpLnp1Init(void);
#endif

55
ops/abCOpLog.c Normal file
View File

@ -0,0 +1,55 @@
/*
abCOpLog.c
By: Jeremy Rand
*/
#include <math.h>
#include <stdio.h>
#include "abCError.h"
#include "abCStack.h"
#include "expr/abCExpr.h"
#include "expr/abCExpReal.h"
#include "ops/abCOp.h"
#include "ops/abCOpLog.h"
#define LOG_NAME "LOG"
static void logExecute(void);
void abCalcOpLogInit(void)
{
abCalcOpRegister(LOG_NAME, logExecute);
}
void logExecute(void)
{
abCalcExpr result;
AB_CALC_OP_ONE_ARG(LOG_NAME);
if (expr->type != abCalcExprTypeReal) {
abCalcRaiseError(abCalcBadArgTypeError, LOG_NAME);
return;
}
if (expr->u.real == 0.0) {
abCalcRaiseError(abCalcInfiniteResultError, LOG_NAME);
return;
}
if (expr->u.real < 0.0) {
abCalcRaiseError(abCalcComplexResultError, LOG_NAME);
return;
}
abCalcExprRealSet(&result, log10(expr->u.real));
abCalcStackExprPop(NULL);
abCalcStackExprPush(&result);
}

14
ops/abCOpLog.h Normal file
View File

@ -0,0 +1,14 @@
/*
abCOpLog.h
By: Jeremy Rand
*/
#ifndef ABCOPLOG_H
#define ABCOPLOG_H
void abCalcOpLogInit(void);
#endif

42
ops/abCOpPi.c Normal file
View File

@ -0,0 +1,42 @@
/*
abCOpPi.c
By: Jeremy Rand
*/
#include <math.h>
#include <stdio.h>
#include "abCStack.h"
#include "expr/abCExpr.h"
#include "expr/abCExpReal.h"
#include "ops/abCOp.h"
#include "ops/abCOpPi.h"
#define PI_NAME "PI"
static void piExecute(void);
void abCalcOpPiInit(void)
{
abCalcOpRegister(PI_NAME, piExecute);
}
void piExecute(void)
{
abCalcExpr result;
#ifdef ABCALC_GSOS
abCalcExprRealSet(&result, 2.0 * asin(1.0));
#else
abCalcExprRealSet(&result, M_PI);
#endif
abCalcStackExprPush(&result);
}

14
ops/abCOpPi.h Normal file
View File

@ -0,0 +1,14 @@
/*
abCOpPi.h
By: Jeremy Rand
*/
#ifndef ABCOPPI_H
#define ABCOPPI_H
void abCalcOpPiInit(void);
#endif

46
ops/abCOpSin.c Normal file
View File

@ -0,0 +1,46 @@
/*
abCOpSin.c
By: Jeremy Rand
*/
#include <math.h>
#include <stdio.h>
#include "abCError.h"
#include "abCStack.h"
#include "expr/abCExpr.h"
#include "expr/abCExpReal.h"
#include "ops/abCOp.h"
#include "ops/abCOpSin.h"
#define SIN_NAME "SIN"
static void sinExecute(void);
void abCalcOpSinInit(void)
{
abCalcOpRegister(SIN_NAME, sinExecute);
}
void sinExecute(void)
{
abCalcExpr result;
AB_CALC_OP_ONE_ARG(SIN_NAME);
if (expr->type != abCalcExprTypeReal) {
abCalcRaiseError(abCalcBadArgTypeError, SIN_NAME);
return;
}
abCalcExprRealSet(&result, sin(expr->u.real));
abCalcStackExprPop(NULL);
abCalcStackExprPush(&result);
}

14
ops/abCOpSin.h Normal file
View File

@ -0,0 +1,14 @@
/*
abCOpSin.h
By: Jeremy Rand
*/
#ifndef ABCOPSIN_H
#define ABCOPSIN_H
void abCalcOpSinInit(void);
#endif

46
ops/abCOpSinh.c Normal file
View File

@ -0,0 +1,46 @@
/*
abCOpSinh.c
By: Jeremy Rand
*/
#include <math.h>
#include <stdio.h>
#include "abCError.h"
#include "abCStack.h"
#include "expr/abCExpr.h"
#include "expr/abCExpReal.h"
#include "ops/abCOp.h"
#include "ops/abCOpSinh.h"
#define SINH_NAME "SINH"
static void sinhExecute(void);
void abCalcOpSinhInit(void)
{
abCalcOpRegister(SINH_NAME, sinhExecute);
}
void sinhExecute(void)
{
abCalcExpr result;
AB_CALC_OP_ONE_ARG(SINH_NAME);
if (expr->type != abCalcExprTypeReal) {
abCalcRaiseError(abCalcBadArgTypeError, SINH_NAME);
return;
}
abCalcExprRealSet(&result, sinh(expr->u.real));
abCalcStackExprPop(NULL);
abCalcStackExprPush(&result);
}

14
ops/abCOpSinh.h Normal file
View File

@ -0,0 +1,14 @@
/*
abCOpSinh.h
By: Jeremy Rand
*/
#ifndef ABCOPSINH_H
#define ABCOPSINH_H
void abCalcOpSinhInit(void);
#endif

46
ops/abCOpSq.c Normal file
View File

@ -0,0 +1,46 @@
/*
abCOpSq.c
By: Jeremy Rand
*/
#include <math.h>
#include <stdio.h>
#include "abCError.h"
#include "abCStack.h"
#include "expr/abCExpr.h"
#include "expr/abCExpReal.h"
#include "ops/abCOp.h"
#include "ops/abCOpSq.h"
#define SQ_NAME "SQ"
static void sqExecute(void);
void abCalcOpSqInit(void)
{
abCalcOpRegister(SQ_NAME, sqExecute);
}
void sqExecute(void)
{
abCalcExpr result;
AB_CALC_OP_ONE_ARG(SQ_NAME);
if (expr->type != abCalcExprTypeReal) {
abCalcRaiseError(abCalcBadArgTypeError, SQ_NAME);
return;
}
abCalcExprRealSet(&result, expr->u.real * expr->u.real);
abCalcStackExprPop(NULL);
abCalcStackExprPush(&result);
}

14
ops/abCOpSq.h Normal file
View File

@ -0,0 +1,14 @@
/*
abCOpSq.h
By: Jeremy Rand
*/
#ifndef ABCOPSQ_H
#define ABCOPSQ_H
void abCalcOpSqInit(void);
#endif

46
ops/abCOpSqrt.c Normal file
View File

@ -0,0 +1,46 @@
/*
abCOpSqrt.c
By: Jeremy Rand
*/
#include <math.h>
#include <stdio.h>
#include "abCError.h"
#include "abCStack.h"
#include "expr/abCExpr.h"
#include "expr/abCExpReal.h"
#include "ops/abCOp.h"
#include "ops/abCOpSqrt.h"
#define SQRT_NAME "SQRT"
static void sqrtExecute(void);
void abCalcOpSqrtInit(void)
{
abCalcOpRegister(SQRT_NAME, sqrtExecute);
}
void sqrtExecute(void)
{
abCalcExpr result;
AB_CALC_OP_ONE_ARG(SQRT_NAME);
if (expr->type != abCalcExprTypeReal) {
abCalcRaiseError(abCalcBadArgTypeError, SQRT_NAME);
return;
}
abCalcExprRealSet(&result, sqrt(expr->u.real));
abCalcStackExprPop(NULL);
abCalcStackExprPush(&result);
}

14
ops/abCOpSqrt.h Normal file
View File

@ -0,0 +1,14 @@
/*
abCOpSqrt.h
By: Jeremy Rand
*/
#ifndef ABCOPSQRT_H
#define ABCOPSQRT_H
void abCalcOpSqrtInit(void);
#endif

45
ops/abCOpSwap.c Normal file
View File

@ -0,0 +1,45 @@
/*
abCOpSwap.c
By: Jeremy Rand
*/
#include <math.h>
#include <stdio.h>
#include <string.h>
#include "abCError.h"
#include "abCStack.h"
#include "expr/abCExpr.h"
#include "ops/abCOp.h"
#include "ops/abCOpSwap.h"
#define SWAP_NAME "SWAP"
static void swapExecute(void);
void abCalcOpSwapInit(void)
{
abCalcOpRegister(SWAP_NAME, swapExecute);
}
void swapExecute(void)
{
abCalcExpr result1;
abCalcExpr result2;
AB_CALC_OP_TWO_ARGS(SWAP_NAME);
memcpy(&result2, expr2, sizeof(result2));
memcpy(&result1, expr1, sizeof(result1));
abCalcStackExprPop(NULL);
abCalcStackExprPop(NULL);
abCalcStackExprPush(&result1);
abCalcStackExprPush(&result2);
}

14
ops/abCOpSwap.h Normal file
View File

@ -0,0 +1,14 @@
/*
abCOpSwap.h
By: Jeremy Rand
*/
#ifndef ABCOPSWAP_H
#define ABCOPSWAP_H
void abCalcOpSwapInit(void);
#endif

46
ops/abCOpTan.c Normal file
View File

@ -0,0 +1,46 @@
/*
abCOpTan.c
By: Jeremy Rand
*/
#include <math.h>
#include <stdio.h>
#include "abCError.h"
#include "abCStack.h"
#include "expr/abCExpr.h"
#include "expr/abCExpReal.h"
#include "ops/abCOp.h"
#include "ops/abCOpTan.h"
#define TAN_NAME "TAN"
static void tanExecute(void);
void abCalcOpTanInit(void)
{
abCalcOpRegister(TAN_NAME, tanExecute);
}
void tanExecute(void)
{
abCalcExpr result;
AB_CALC_OP_ONE_ARG(TAN_NAME);
if (expr->type != abCalcExprTypeReal) {
abCalcRaiseError(abCalcBadArgTypeError, TAN_NAME);
return;
}
abCalcExprRealSet(&result, tan(expr->u.real));
abCalcStackExprPop(NULL);
abCalcStackExprPush(&result);
}

14
ops/abCOpTan.h Normal file
View File

@ -0,0 +1,14 @@
/*
abCOpTan.h
By: Jeremy Rand
*/
#ifndef ABCOPTAN_H
#define ABCOPTAN_H
void abCalcOpTanInit(void);
#endif

46
ops/abCOpTanh.c Normal file
View File

@ -0,0 +1,46 @@
/*
abCOpTanh.c
By: Jeremy Rand
*/
#include <math.h>
#include <stdio.h>
#include "abCError.h"
#include "abCStack.h"
#include "expr/abCExpr.h"
#include "expr/abCExpReal.h"
#include "ops/abCOp.h"
#include "ops/abCOpTanh.h"
#define TANH_NAME "TANH"
static void tanhExecute(void);
void abCalcOpTanhInit(void)
{
abCalcOpRegister(TANH_NAME, tanhExecute);
}
void tanhExecute(void)
{
abCalcExpr result;
AB_CALC_OP_ONE_ARG(TANH_NAME);
if (expr->type != abCalcExprTypeReal) {
abCalcRaiseError(abCalcBadArgTypeError, TANH_NAME);
return;
}
abCalcExprRealSet(&result, tanh(expr->u.real));
abCalcStackExprPop(NULL);
abCalcStackExprPush(&result);
}

14
ops/abCOpTanh.h Normal file
View File

@ -0,0 +1,14 @@
/*
abCOpTanh.h
By: Jeremy Rand
*/
#ifndef ABCOPTANH_H
#define ABCOPTANH_H
void abCalcOpTanhInit(void);
#endif