|
Purpose:
|
Provides methods for the term mathematical function that returns a single dimensional element of a multidimensional function.
|
|
|
Derivation:
|
term_law : multiple_law : law : ACIS_OBJECT : -
|
|
|
SAT Identifier:
|
"TERM"
|
|
|
Filename:
|
law/lawutil/main_law.hxx
|
|
|
Description:
|
The
term_law class supports the
term_law function. It is used for picking off elements out of an array.
|
|
|
For example, assume
my_law is a vector field defined by
"vec(x, x+1, x+2, x+3)". A declaration in Scheme like
(law:eval "term(my_law, 4)" 1) evaluates the fourth coordinate of
my_law,
x+3, at the value 1. It returns 4. A declaration like
(law:eval "term(my_law, 3)" 1) evaluates the third coordinate of
my_law,
x+2, at the value 1. It returns 3.
|
|
|
Constructor:
|
public: term_law::term_law
(
|
|
|
law** in_sublaw,
|
// array of sublaws
|
|
|
int in_dim
|
// size of array
|
|
|
);
|
|
|
C++ constructor, creating a
term_law. This has two or more pointers to sublaws passed in as arguments.
|
|
|
|
|
|
|
public: term_law::term_law
(
|
|
|
law* in_law,
|
// pointer to law
|
|
|
int which
|
// which law
|
|
|
|
|
// (starts at 1)
|
|
|
);
|
|
|
C++ constructor, creating a
term_law. This has two or more pointers to laws passed in as arguments.
|
|
|
|
|
Methods:
|
public: char const* term_law::class_name
();
|
|
|
This method returns a string that contains the name of this class. It is provided as a user-friendly interface to laws.
|
|
|
|
|
|
|
protected: law* term_law::deriv
(
|
|
|
int which
|
// variable to take
|
|
|
|
= 0
|
// derivative with
|
|
|
|
|
// respect to default
|
|
|
|
|
// value (X or A1)
|
|
|
) const;
|
|
|
This method returns a law pointer that is the derivative of the given law with respect to the
which variable. Variables in
C++ are numbered starting at zero (0). The default is to take a derivative with respect to the first variable, which in a law function string is
A1 or
X. The variables
X,
Y, and
Z are equivalent to the indices 0, 1, and 2, respectively.
|
|
|
The
deriv method implements the code to perform the actual derivative calculation and caches its value in memory. All classes derived from
law (or its children) must implement their own
deriv method.
|
|
|
The
deriv method should
not be called directly by applications. Applications should call the
derivative method instead, which is inherited by all classes derived from
law. The
derivative method accesses the cached derivative value in memory, if one exists; otherwise it calls the
deriv method.
|
|
|
|
|
|
|
public: void term_law::evaluate
(
|
|
|
double const* x,
|
// values used in
|
|
|
|
|
// evaluation
|
|
|
double* answer
|
// multi-dimension answer
|
|
|
|
|
// range for evaluation
|
|
|
) const;
|
|
|
This method takes two pointers to memory that the caller is responsible for creating and freezing. The
x argument tells where to evaluate the laws. This is passed into all laws making up the maximum function. This can be more than one dimension. The
answer argument returns the result of the evaluation from all sublaws that is maximum. This can be more than one dimension.
x should be the size returned by the
take_dim method, and
answer should be the size returned by the
return_dim method. All derived law classes must have this method or inherit it.
|
|
|
|
|
|
|
public: static int term_law::id
();
|
|
|
This method should not be called directly by the application. All derived law classes must have this method. The
isa,
id, and and
type methods are used to identify a law's class type.
|
|
|
|
|
|
|
public: logical term_law::isa
(
|
|
|
int t
|
// id method return
|
|
|
) const;
|
|
|
All derived law classes must have this method. The
isa,
id, and and
type methods are used to identify a law's class type. The methods should be the same for all law classes with the exception of the
isa method that calls the
isa method of its parent class. To test to see if a law is a given type, use
test_law->isa(constant_law::id()). If
test_law is a
constant_law or is derived from the
constant_law class, this returns
TRUE.
|
|
|
|
|
|
|
public: multiple_law* term_law::make_one
(
|
|
|
law** subs,
|
// array of sublaws
|
|
|
int size
|
// size of array
|
|
|
) const;
|
|
|
Returns a pointer to a law of this type. Used by parsing to create an instance of this law.
|
|
|
|
|
|
|
public: int term_law::return_size
() const;
|
|
|
Returns the dimension of the range (output) of the law. The default is 1. All derived law classes must have this method or inherit it.
|
|
|
|
|
|
|
public: virtual law* term_law::sub_simplify
(
|
|
|
int level
|
|
// level of
|
|
|
|
= 0,
|
|
// simplification
|
|
|
char const*& what
|
|
// text string
|
|
|
|
= * (char const** )
|
|
// describing the
|
|
|
|
NULL_REF
|
|
// simplified law
|
|
|
) const;
|
|
|
This is a member function that may be overloaded by derived classes to provide assistance to the simplifier. It helps the simplifier in dealing with this particular law. This method is called by the simplifier but generally not called directly by the application.
|
|
|
For example, a law class such as
plus_law might use an equation "x + x". The
sub_simplify method could return this equation as "2*x". The
sub_simplify method can access the private members of the law that the simplifier does not have access to. Most laws simply inherit a function that returns null.
|
|
|
|
|
|
|
public: char const* term_law::symbol
(
|
|
|
law_symbol_type type
|
// type of law symbol
|
|
|
|
= DEFAULT
|
// standard ACIS type
|
|
|
) const;
|
|
|
Returns the string that represents this law class's symbol. The symbol is used for parsing the law and for saving and restoring law-based geometry. For a law to be saved and restored, it must have or inherit this method.
|
|
|
The default law symbol for this class is
TERM.
|
|
|
|
|
|
|
public: int term_law::take_size
() const;
|
|
|
Returns the dimension of the law's domain (input). The default is 1. All derived law classes must have this method or inherit it.
|
|
|
|
|
|
|
public: int term_law::type
() const;
|
|
|
All derived law classes must have this method. The
isa,
id, and and
type methods are used to identify a law's class type. The methods should be the same for all law classes.
|
|
|
|
|
|
Related Fncs:
|
initialize_law, terminate_law
|