-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed max order/param orders, docs updated, global variable getter/se…
…tter
- Loading branch information
1 parent
f0cbc77
commit 4897542
Showing
22 changed files
with
860 additions
and
785 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# [Definitions](@id definitions) | ||
*This section is incomplete, and will be expanded in the near future* | ||
|
||
## [Custom Truncation Orders](@id cto) | ||
GTPSA allows for significant customization in the truncation of specific variables within a monomial of the truncated power series (TPS). One can specify individually the truncation orders for each variable in a truncated power series, as well as the maximum truncation order for an entire monomial in the TPS. This is best shown with an example: | ||
|
||
Suppose we'd like to express a function ``f(x_1,x_2)`` as a truncated power series, and keep only terms that are up to 1st-order in ``x_1`` but up to 2nd order in ``x_2``; basically, we should not have any monomials where ``x_1`` has an exponent > 1, nor any monomials where ``x_2`` has an exponent > 2. GTPSA allows one to select the **individual truncation orders** for variables in a monomial in this manner. The next question to consider is the **maximum truncation order** for the entire monomial; in the above example, note that the 3rd-order term ``x_1x_2^2`` follows the rules we layed out so far. But what if we'd also like to truncate all monomials with order 3 and above, and not allow this monomial? This can be achieved by setting the maximum truncation order equal to 2. When defining a GTPSA, the user must always specify the maximum truncation order, which when specifying individual truncation orders must lie within the range ``[\max{(\textrm{individual truncation orders})}, \sum{(\textrm{individual truncation orders})}]``. If individual truncation orders are not specified, then they are automatically set to the maximum truncation order. | ||
|
||
**Example: allowed monomials for ``f(x_1,x_2)`` with individual variable truncation orders [1,2] and different maximum truncation orders:** | ||
|
||
| Exponents | Max Order = 2 | Max Order = 3 | | ||
| :-------: | :-----------: | :-----------: | | ||
| ``1\quad 0`` | ✅ | ✅ | | ||
| ``0\quad 1`` | ✅ | ✅ | | ||
| ``2\quad 0`` | ❌ | ❌ | | ||
| ``1\quad 1`` | ✅ | ✅ | | ||
| ``0\quad 2`` | ✅ | ✅ | | ||
| ``3\quad 0`` | ❌ | ❌ | | ||
| ``2\quad 1`` | ❌ | ❌ | | ||
| ``1\quad 2`` | ❌ | ✅ | | ||
| ``0\quad 3`` | ❌ | ❌ | | ||
|
||
|
||
## Parameters | ||
GTPSA allows one to explicitly distinguish between *variables* and *parameters*. Generally, a variable would be a dependent variable in a differential equation, and a parameter would be a variation in something defining or influencing the system (for example, in a harmonic oscillator the restoring constant ``k`` would be a parameter). Individual truncation orders can be specified for the parameters in the same way as [described for the variables](@ref cto), however there is a special extra truncation order the can be specified for solely the parameters part of the monomial, referred to as the **parameter order**. The parameter order defines the truncation order for only the parameters part of a monomial. | ||
|
||
**Example: allowed monomials for ``f(x_1,k_1,k_2)`` (one variable, two parameters) with individual variable truncation order [1], individual parameter truncation orders [1,1], maximum order = 3, and different parameter orders:** | ||
|
||
| Exponents | Parameter Order = 1 | Parameter Order = 2 | | ||
| :-------: | :-----------: | :-----------: | | ||
| ``0\quad \| \quad 1 \quad 0`` | ✅ | ✅ | | ||
| ``0\quad \| \quad 0 \quad 1`` | ✅ | ✅ | | ||
| ``0\quad \| \quad 1 \quad 1`` | ❌ | ✅ | | ||
| ``1\quad \| \quad 1 \quad 0`` | ✅ | ✅ | | ||
| ``1\quad \| \quad 0 \quad 1`` | ✅ | ✅ | | ||
| ``1\quad \| \quad 1 \quad 1`` | ❌ | ✅ | | ||
(Note: many monomials are excluded for brevity in the above table) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# [`Descriptor`](@id descriptor) | ||
*Defines the number of variables, number of parameters, and order(s) for each in the GTPSA* | ||
## Syntax | ||
``` | ||
d = Descriptor(num_vars, max_order) | ||
d = Descriptor(vars_orders, max_order) | ||
d = Descriptor(num_vars, max_order, num_params, param_order) | ||
d = Descriptor(vars_orders, max_order, params_orders, param_order) | ||
GTPSA.desc_current = d | ||
``` | ||
|
||
## Description | ||
`d = Descriptor(num_vars, max_order)` defines a GTPSA `Descriptor` with `num_vars` variables and a maximum truncation order `max_order` | ||
|
||
`d = Descriptor(vars_orders, max_order)` defines a GTPSA `Descriptor` with `length(var_orders)` variables each having individual truncation orders specified in the `var_orders` vector, and a maximum truncation order `max_order` for the entire monomial | ||
|
||
`d = Descriptor(num_vars, max_order, num_params, param_order)` defines a GTPSA `Descriptor` with `num_vars` variables and `num_params` parameters. The parameters part of a monomial is truncated at `param_order`, and the entire monomial is truncated at `max_order` (so `param_order <= max_order`) | ||
|
||
`d = Descriptor(vars_orders, max_order, params_orders, param_order)` defines a GTPSA `Descriptor` with `length(var_orders)` variables each having individual truncation orders specified in the `vars_orders` vector, and `length(param_orders)` parameters each having individual truncation orders specified in the `params_orders` vector. The parameters part of the monomial is truncated at `param_order`, and the entire monomial is truncated at `max_order` (so `param_order <= max_order`) | ||
|
||
----- | ||
|
||
`GTPSA.desc_current` is a global variable that is set each time a user creates a new `Descriptor`, and can also be set manually by a user. `GTPSA.desc_current` defines the `Descriptor` to use when that information is not explicitly (or implicitly in a TPS copy constructor) available, e.g. when calling `TPS(a)` where `a` is not a `TPS`. This also allows one to use general `Number` commands like `convert(TPS, a)` and `zeros(TPS, 6)`. | ||
|
||
|
||
## Examples | ||
```@repl desc | ||
using GTPSA #hide | ||
d1 = Descriptor(2, 10) | ||
d2 = Descriptor([1, 2, 3], 5) | ||
d3 = Descriptor(3, 4, 1, 2) | ||
d4 = Descriptor([6, 5], 8, [4, 3], 7) | ||
GTPSA.desc_current = d1 | ||
``` | ||
|
||
## Documentation | ||
```@docs | ||
Descriptor | ||
``` |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# [Global Variables] (@id global) | ||
The following non-constant global variables can be set: | ||
|
||
```julia | ||
desc_current::Descriptor # Current Descriptor to use | ||
show_eps::Float64 = 0.0 # Print epsilon | ||
show_sparse::Bool = false # Use sparse monomial print | ||
show_header::Bool = false # Print a header above each TPS | ||
``` | ||
|
||
**`desc_current`** defines the `Descriptor` to use when that information is not explicitly (or implicitly in a TPS copy constructor) available, e.g. when calling `TPS(a)` where `a` is not a `TPS`. This also allows one to use general `Number` commands like `convert(TPS, a)` and `zeros(TPS, 6)` | ||
|
||
**`show_eps`** defines the value below which the absolute value of a monomial coefficient is NOT printed | ||
|
||
**`show_sparse`** specifies whether the sparse monomial format is used for printing. This is useful for GTPSAs containing a large number of variables and parameters | ||
|
||
**`show_header`** specifies whether or not to print the GTPSA `Descriptor` information above each TPS output | ||
|
||
----- | ||
|
||
Global variables can be get/set using either the standard syntax (e.g. `GTPSA.show_header = true`), or using the helper functions `getGTPSA` and `setGTPSA!`. | ||
|
||
## Examples | ||
|
||
```@repl | ||
using GTPSA; GTPSA.show_sparse = false; GTPSA.show_header=false; #hide | ||
d1 = Descriptor(1, 6); | ||
x = vars() | ||
GTPSA.show_sparse = true; | ||
x | ||
setGTPSA!("show_sparse", false); | ||
getGTPSA("show_sparse") | ||
x | ||
``` |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.