Isis Developer Reference
Calculator.h
Go to the documentation of this file.
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 
8 // Calculator.h
9 #ifndef CALCULATOR_H_
10 #define CALCULATOR_H_
11 
12 #include "Buffer.h"
13 
14 // I'm not sure how to forward declare the iterators
15 #include <QVector>
16 
17 template<class T> class QStack;
18 template<class T> class QVector;
19 
20 namespace Isis {
55  class Calculator {
56  public:
57  Calculator(); // Constructor
59  virtual ~Calculator();
60 
61  // Math methods
62  void Negative();
63  void Multiply();
64  void Add();
65  void Subtract();
66  void Divide();
67  void Modulus();
68 
69  void Exponent();
70  void SquareRoot();
71  void AbsoluteValue();
72  void Log();
73  void Log10();
74 
75  void LeftShift();
76  void RightShift();
77  void MinimumPixel();
78  void MaximumPixel();
79  void MinimumLine();
80  void MaximumLine();
81  void Minimum2();
82  void Maximum2();
83  void GreaterThan();
84  void LessThan();
85  void Equal();
86  void LessThanOrEqual();
87  void GreaterThanOrEqual();
88  void NotEqual();
89  void And();
90  void Or();
91 
92  void Sine();
93  void Cosine();
94  void Tangent();
95  void Secant();
96  void Cosecant();
97  void Cotangent();
98  void Arcsine();
99  void Arccosine();
100  void Arctangent();
101  void Arctangent2();
102  void SineH();
103  void CosineH();
104  void TangentH();
105  void ArcsineH();
106  void ArccosineH();
107  void ArctangentH();
108 
109  // Stack methods
110  void Push(double scalar);
111  void Push(Buffer &buff);
112  void Push(QVector<double> &vect);
113  QVector<double> Pop(bool keepSpecials = false);
114  void PrintTop();
115  bool Empty();
116  virtual void Clear();
117 
118  protected:
119  void PerformOperation(QVector<double> &results,
120  QVector<double>::iterator arg1Start,
122  double operation(double));
123  void PerformOperation(QVector<double> &results,
124  QVector<double>::iterator arg1Start,
126  QVector<double>::iterator arg2Start,
128  double operation(double, double));
129 
131  int StackSize();
132 
133  private:
135  QStack< QVector<double> > * p_valStack;
136  };
137 };
138 
139 #endif
Isis::Calculator::Push
void Push(double scalar)
Push a scalar onto the stack.
Definition: Calculator.cpp:893
Isis::CosecantOperator
double CosecantOperator(double a)
Returns the cosecant of the input a.
Definition: Calculator.cpp:195
Isis::Calculator::Arcsine
void Arcsine()
Pops one element and push the arcsine.
Definition: Calculator.cpp:767
Isis::Calculator::Cosine
void Cosine()
Pops one element and push the cosine.
Definition: Calculator.cpp:717
Isis::Calculator::Tangent
void Tangent()
Pops one element and push the tangent.
Definition: Calculator.cpp:727
QStack
This is free and unencumbered software released into the public domain.
Definition: Calculator.h:17
Isis::ModulusOperator
double ModulusOperator(double a, double b)
Returns the modulus of a by b.
Definition: Calculator.cpp:269
Isis::Calculator::Add
void Add()
Pops two elements, adds them, then pushes the sum on the stack.
Definition: Calculator.cpp:330
Isis::Calculator::Cosecant
void Cosecant()
Pops one element and push the cosecant.
Definition: Calculator.cpp:737
Calculator.h
Isis::CotangentOperator
double CotangentOperator(double a)
Returns the cotangent of the input a.
Definition: Calculator.cpp:218
Isis::Calculator::Or
void Or()
Pop two elements, OR them, then push the result on the stack.
Definition: Calculator.cpp:693
Isis::Calculator::PrintTop
void PrintTop()
Print the vector at the top of the stack.
Definition: Calculator.cpp:989
Isis::Calculator::TangentH
void TangentH()
Pops one element and push the hyperbolic tangent.
Definition: Calculator.cpp:860
SpecialPixel.h
Isis::Calculator::Multiply
void Multiply()
Pops two elements, multiplies them, then pushes the product on the stack.
Definition: Calculator.cpp:317
Isis::Calculator::Modulus
void Modulus()
Pops two elements, mods them, then pushes the result on the stack.
Definition: Calculator.cpp:366
Isis::IsNullPixel
bool IsNullPixel(const double d)
Returns if the input pixel is null.
Definition: SpecialPixel.h:235
Isis::Calculator::Equal
void Equal()
Pop two elements off the stack and compare them to see where one is equal to the other,...
Definition: Calculator.cpp:617
Isis::Calculator
Calculator for arrays.
Definition: Calculator.h:55
Isis::Calculator::Arctangent
void Arctangent()
Pops one element and push the arctangent.
Definition: Calculator.cpp:787
Isis::IsHrsPixel
bool IsHrsPixel(const double d)
Returns if the input pixel is high representation saturation.
Definition: SpecialPixel.h:271
Isis::Calculator::CosineH
void CosineH()
Pops one element and push the hyperbolic cosine.
Definition: Calculator.cpp:850
Isis::LessThanOperator
double LessThanOperator(double a, double b)
Returns 1.0 if a is less than b.
Definition: Calculator.cpp:131
InfixToPostfix.h
Isis::Calculator::Empty
bool Empty()
Check if the stack is empty.
Definition: Calculator.cpp:1013
Isis::NegateOperator
double NegateOperator(double a)
Returns the nagative of the input parameter.
Definition: Calculator.cpp:53
Isis::Calculator::Sine
void Sine()
Pops one element and push the sine.
Definition: Calculator.cpp:707
Isis::Calculator::Divide
void Divide()
Pops two, divides them, then pushes the quotient on the stack.
Definition: Calculator.cpp:354
Isis::Calculator::~Calculator
virtual ~Calculator()
Virtual Constructor.
Definition: Calculator.cpp:39
Isis::GreaterThanOperator
double GreaterThanOperator(double a, double b)
Returns 1.0 if a is greater than b.
Definition: Calculator.cpp:118
Isis::Calculator::SineH
void SineH()
Pops one element and push the hyperbolic sine.
Definition: Calculator.cpp:840
Isis::IsSpecial
bool IsSpecial(const double d)
Returns if the input pixel is special.
Definition: SpecialPixel.h:197
Isis::BitwiseAndOperator
double BitwiseAndOperator(double a, double b)
Returns the result of a bitwise AND accross a and b.
Definition: Calculator.cpp:243
Isis::Calculator::Subtract
void Subtract()
Pops two elements, subtracts them, then pushes the difference on the stack.
Definition: Calculator.cpp:342
Isis::GreaterThanOrEqualOperator
double GreaterThanOrEqualOperator(double a, double b)
Returns 1.0 if a is greater than or equal to b.
Definition: Calculator.cpp:157
Isis::Hrs
const double Hrs
Value for an Isis High Representation Saturation pixel.
Definition: SpecialPixel.h:117
Isis::MaximumOperator
double MaximumOperator(double a, double b)
Returns the max of a and b.
Definition: Calculator.cpp:281
Isis::MinimumOperator
double MinimumOperator(double a, double b)
Returns the min of a and b.
Definition: Calculator.cpp:296
Isis::Buffer
Buffer for reading and writing cube data.
Definition: Buffer.h:53
Isis::Calculator::MinimumLine
void MinimumLine()
Pop one element, then push the minimum on the stack.
Definition: Calculator.cpp:518
Isis::Lrs
const double Lrs
Value for an Isis Low Representation Saturation pixel.
Definition: SpecialPixel.h:99
Buffer.h
Isis::Calculator::Maximum2
void Maximum2()
Not implemented in Calculator.cpp.
Isis::Calculator::AbsoluteValue
void AbsoluteValue()
Pop an element, compute its absolute value, then push the result on the stack.
Definition: Calculator.cpp:407
Isis::DivideOperator
double DivideOperator(double a, double b)
Returns the result of dividing a by b.
Definition: Calculator.cpp:79
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
Isis::Calculator::Cotangent
void Cotangent()
Pops one element and push the cotangent.
Definition: Calculator.cpp:757
Isis::Calculator::ArcsineH
void ArcsineH()
Pops one element and push the inverse hyperbolic sine.
Definition: Calculator.cpp:797
Isis::BitwiseOrOperator
double BitwiseOrOperator(double a, double b)
Returns the result of a bitwise OR across a and b.
Definition: Calculator.cpp:256
Isis::Round
int Round(double a)
Returns the result of rounding the input a to the closest integer.
Definition: Calculator.cpp:230
Isis::Calculator::ArccosineH
void ArccosineH()
Pops one element and push the inverse hyperbolic cosine.
Definition: Calculator.cpp:807
Isis::Calculator::Log10
void Log10()
Pop an element, compute its base 10 log, then push the result on the stack.
Definition: Calculator.cpp:429
Isis::SecantOperator
double SecantOperator(double a)
Returns the secant of the input a.
Definition: Calculator.cpp:207
Isis::Calculator::SquareRoot
void SquareRoot()
Pop an element, compute its square root, then push the root on the stack.
Definition: Calculator.cpp:397
Isis::MultiplyOperator
double MultiplyOperator(double a, double b)
Returns the result of a multiplied by b.
Definition: Calculator.cpp:66
Isis::Calculator::RightShift
void RightShift()
Pop the top element, then perform a right shift with zero fill.
Definition: Calculator.cpp:480
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::Calculator::Arccosine
void Arccosine()
Pops one element and push the arccosine.
Definition: Calculator.cpp:777
Isis::IsLisPixel
bool IsLisPixel(const double d)
Returns if the input pixel is low instrument saturation.
Definition: SpecialPixel.h:295
Isis::Calculator::LeftShift
void LeftShift()
Pop the top element, then perform a left shift with zero fill.
Definition: Calculator.cpp:441
Isis::IsLrsPixel
bool IsLrsPixel(const double d)
Returns if the input pixel is low representation saturation.
Definition: SpecialPixel.h:307
Isis::SubtractOperator
double SubtractOperator(double a, double b)
Returns the result of subtracting b from a.
Definition: Calculator.cpp:105
Isis::Null
const double Null
Value for an Isis Null pixel.
Definition: SpecialPixel.h:95
Isis::Calculator::GreaterThanOrEqual
void GreaterThanOrEqual()
Pop two elements off the stack and compare them to see where one is greater than or equal to the othe...
Definition: Calculator.cpp:632
Isis::IsHisPixel
bool IsHisPixel(const double d)
Returns if the input pixel is high instrument saturation.
Definition: SpecialPixel.h:283
Isis::Calculator::LessThan
void LessThan()
Pop two elements off the stack and compare them to see where one is less than the other,...
Definition: Calculator.cpp:602
IException.h
std
Namespace for the standard library.
Isis::Calculator::Pop
QVector< double > Pop(bool keepSpecials=false)
Pop an element off the stack.
Definition: Calculator.cpp:949
Isis::Calculator::GreaterThan
void GreaterThan()
Pop two elements off the stack and compare them to see where one is greater than the other,...
Definition: Calculator.cpp:587
Isis::Calculator::PerformOperation
void PerformOperation(QVector< double > &results, QVector< double >::iterator arg1Start, QVector< double >::iterator arg1End, double operation(double))
Performs the mathematical operations on each argument.
Definition: Calculator.cpp:1037
Isis::AddOperator
double AddOperator(double a, double b)
Returns the result of additing a with b.
Definition: Calculator.cpp:92
Isis::Calculator::LessThanOrEqual
void LessThanOrEqual()
Pop two elements off the stack and compare them to see where one is less than or equal to the other,...
Definition: Calculator.cpp:647
Isis::Calculator::ArctangentH
void ArctangentH()
Pops one element and push the inverse hyperbolic tangent.
Definition: Calculator.cpp:817
Isis::Calculator::Arctangent2
void Arctangent2()
Pops two elements and push the arctangent.
Definition: Calculator.cpp:827
Isis::Buffer::size
int size() const
Returns the total number of pixels in the shape buffer.
Definition: Buffer.h:97
Isis::Calculator::Minimum2
void Minimum2()
Not implemented in Calculator.cpp.
Isis::Calculator::MaximumLine
void MaximumLine()
Pop one element, then push the maximum on the stack.
Definition: Calculator.cpp:537
Isis::IString
Adds specific functionality to C++ strings.
Definition: IString.h:165
Isis::Calculator::Exponent
void Exponent()
Pops two elements, computes the power then pushes the result on the stack The exponent has to be a sc...
Definition: Calculator.cpp:382
Isis::Calculator::StackSize
int StackSize()
Returns the current stack size.
Definition: Calculator.cpp:874
QVector< double >
Isis::Calculator::Clear
virtual void Clear()
Clear out the stack.
Definition: Calculator.cpp:1021
Isis::NotEqualOperator
double NotEqualOperator(double a, double b)
Returns 1.0 is a is not equal to b.
Definition: Calculator.cpp:183
Isis::Calculator::Log
void Log()
Pop an element, compute its log, then push the result on the stack.
Definition: Calculator.cpp:419
Isis::Calculator::Secant
void Secant()
Pops one element and push the secant.
Definition: Calculator.cpp:747
Isis::Calculator::Calculator
Calculator()
The code that performs math operations is designed to call a function and use the result.
Definition: Calculator.cpp:32
Isis::Calculator::MaximumPixel
void MaximumPixel()
Pop two elements, then push the maximum on a pixel by pixel basis back on the stack.
Definition: Calculator.cpp:572
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::Calculator::NotEqual
void NotEqual()
Pop two elements off the stack and compare them to see where one is not equal to the other,...
Definition: Calculator.cpp:662
Isis::EqualOperator
double EqualOperator(double a, double b)
Returns 1.0 if a is equal ot b.
Definition: Calculator.cpp:144
Isis::Calculator::MinimumPixel
void MinimumPixel()
Pop two elements, then push the minimum on a pixel by pixel basis back on the stack.
Definition: Calculator.cpp:557
Isis::Calculator::Negative
void Negative()
Pops an element, negates it, then pushes the result.
Definition: Calculator.cpp:307
Isis::LessThanOrEqualOperator
double LessThanOrEqualOperator(double a, double b)
Returns 1.0 if a is less than or eqaul to b.
Definition: Calculator.cpp:170
Isis::Calculator::And
void And()
Pop two elements, AND them, then push the result on the stack.
Definition: Calculator.cpp:679