-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Nested Taylors #126
base: master
Are you sure you want to change the base?
WIP: Nested Taylors #126
Conversation
|
||
|
||
#number of variables in a nested polynomial | ||
function get_nested_numvars{T<:Number}(a::Taylor1{T}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may be some type instability in this function, since a_aux
may change of type. I suggest to do the same but recursively (so call again get_nested_numvars
), which may require to define another method, where a
is not an AbstractSeries
.
end | ||
|
||
|
||
function nest{T<:Number}(a::Taylor1{T},num_vars::Integer,dim_a::Integer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again here, a
is changing type, which may affect the performance.
end | ||
|
||
#Shortcut to define an array of independent variables of nested taylors | ||
function set_nested_variables(numvars::Integer,order::Integer,T::Type=Float64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to have this as set_nested_variables(T::Type, numvars::Integer, order::Integer)
which follows the convention we have, for example, to define Taylor1
, and then define a specific method without it, which corresponds to the default Float64
.
Though it is not urgent at the moment, I think it would be neat to have the possibility of different order
s for the different variables, which in this case could be done by passing a Tuple of Int
's of the correct length (numvars
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above, I think there may be type-stability issues here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A possibility, to reduce temporary allocations (and maybe type instability problems too) is to exploit things like Taylor(T, order)
. In the loop in the function, T
would be updated (but it would always be a DataType
!) to get the nesting of the types.
JuliaDiff#118) * Add function-like behavior for Taylor1 * Relocate new code * Add function-like behavior for TaylorN * Fix TaylorN functor methods * Add tests for Taylor1 * Add more Taylor1 tests * Add TaylorN tests; more Taylor1 tests; add missing evaluate methods * Add function-like behavior for HomogeneousPolynomial and corresponding tests * Add missing tests for HomogeneousPolynomial * Add another test for Taylor1s * Fix test * Add extra evaluate method for Taylor1 (suggested by @blas-ko) * Add an evaluate test for mixtures (more to come) * Add tests for mixtures; add/fix evaluate methods * A small fix * Add missing evaluate methods for mixtures and tests * Update docs * Add evaluate method and tests * Fix new method * Update docstrings * Changes suggested by @lbenet 's review
* Added norm methods to get a non-negative Number from an AbstractSeries. Suggestions from @lbenet and @PerezHz * Added some tests for norm. * Add isapprox and auxiliary methods * Add one variable tests for isapprox * Fix isfinite * Add many variable tests * Add NaN test for many variables isfinite * Add isapprox tests for mixtures; fix `real` method for types * Small fix on tests * Fix mixtures tests * Test isapprox for mixtures with BigFloats * Add docstrings * Add docstrings and a couple tests with ≉ * Added more mixture tests for norm. * fixed some norm tests. * Added documentation to abs and norm. * silly fix for abs docs. * Travis fix as proposed by @lbenet. * Fix printing as suggested by @Keno; fix tests * Add one more fix * trigger travis build
* Added function and macro `taylor_expand` for expanding arbitraty functions. * Deleted macros and set order as keyword argument so methods doesnt clash `taylor_expand(f,x0::Int64)` and `taylor_expand(f,order)` clashed. * Added some tests for `taylor_expand`. * un-exported taylor_expand macros. * Updated taylor_expand tests. * Added taylor_expand method for TaylorN and warning if number of variables is changed. * Fix travis issue for taylor_expand (hopefully). * Added taylor_expand! and tests for Taylor1. Followed suggestion from @lbenet. * Add function-like behavior for Taylor1, TaylorN, HomogeneousPolynomial (JuliaDiff#118) * Add function-like behavior for Taylor1 * Relocate new code * Add function-like behavior for TaylorN * Fix TaylorN functor methods * Add tests for Taylor1 * Add more Taylor1 tests * Add TaylorN tests; more Taylor1 tests; add missing evaluate methods * Add function-like behavior for HomogeneousPolynomial and corresponding tests * Add missing tests for HomogeneousPolynomial * Add another test for Taylor1s * Fix test * Add extra evaluate method for Taylor1 (suggested by @blas-ko) * Add an evaluate test for mixtures (more to come) * Add tests for mixtures; add/fix evaluate methods * A small fix * Add missing evaluate methods for mixtures and tests * Update docs * Add evaluate method and tests * Fix new method * Update docstrings * Changes suggested by @lbenet 's review * Added method for evaluating a TaylorN with an array of TaylorNs. * Added taylor_expand! method for TaylorN * Added some test for taylor_expand! * Documentation for taylor_expand and taylor_expand! * Added function and macro `taylor_expand` for expanding arbitraty functions. * Deleted macros and set order as keyword argument so methods doesnt clash `taylor_expand(f,x0::Int64)` and `taylor_expand(f,order)` clashed. * Added some tests for `taylor_expand`. * un-exported taylor_expand macros. * Updated taylor_expand tests. * Added taylor_expand method for TaylorN and warning if number of variables is changed. * Fix travis issue for taylor_expand (hopefully). * Added taylor_expand! and tests for Taylor1. Followed suggestion from @lbenet. * Add function-like behavior for Taylor1, TaylorN, HomogeneousPolynomial (JuliaDiff#118) * Add function-like behavior for Taylor1 * Relocate new code * Add function-like behavior for TaylorN * Fix TaylorN functor methods * Add tests for Taylor1 * Add more Taylor1 tests * Add TaylorN tests; more Taylor1 tests; add missing evaluate methods * Add function-like behavior for HomogeneousPolynomial and corresponding tests * Add missing tests for HomogeneousPolynomial * Add another test for Taylor1s * Fix test * Add extra evaluate method for Taylor1 (suggested by @blas-ko) * Add an evaluate test for mixtures (more to come) * Add tests for mixtures; add/fix evaluate methods * A small fix * Add missing evaluate methods for mixtures and tests * Update docs * Add evaluate method and tests * Fix new method * Update docstrings * Changes suggested by @lbenet 's review * Added method for evaluating a TaylorN with an array of TaylorNs. * Added taylor_expand! method for TaylorN * Added some test for taylor_expand! * Documentation for taylor_expand and taylor_expand! * Corrected silly mistake from rebasing. * Rearanged taylor_expand tests to another place. They use set_variables internally. * called coeff_table directly so it doesn't make a copy. * changed docs for taylor_expand * Changed taylor_expand for TaylorN. * It doesn't use set_variables() anymore. * typeof(x0) is preserved if possible. * Changed taylor_expand! for update! * Added 1 more test... * Little performance and compatibility fix for taylor_expand
* Change the syntax according to new Julia 0.6 directives This includes `struct`, inner constructors and `where` syntax. * Delete use of Compat.jl for compatibility with Julia 0.5. * Drop testing with Julia 0.5 * Delet 0.5 badge in README.md, corrections in the docs * Use {...} after where * Solve inconsistencies introduced in where * Some corrections, mainly in the docs.
* Use explicit recursion for acos in acos! ... ...instead of using asin! * Add internalmutfunct.jl * Add unary add! subst! and other methods, and ammend dictionaries * Small corrections * Add mul! and div! involving numeric coefficients * Rename internalmutfunct.jl to dictmutfunct.jl and export constant_term * Add identity! and another method of constant_term * Add zero! and one! methods * Include in _internalmutfunc_call TayloSeries before the function * Revise the docstrings * Add specific cases depending on the power to `pow!` * Add missing methods for add! and subst! (JuliaDiff#117) * Add missing in-place methods for unary +,- * Add tests for new add!, subst! methods * Add `abs!` * Add `abs2(a)` as `a^2`, and the corresponding `abs2!` * Correct `abs!` so it works for Taylor1{TaylorN{T}} * Import abs2 * Add tests for some mutating functions and dictionary calls * Fix some deprecations warning
* Declared new method for get_variables. * Changed get_variables method so it takes order as a keyword argument. * Added docs & tests for get_variables. * Addition of get_variables to userguide.
* Start indexing in 0 for Taylor1 * Start indexing for TaylorN at 0 * Fix mixtures * Fix mutatingfuncts tests * Small fix for fateman40 test * Disallow setindex! methods for UnitRange/Colon with HomogeneousPolynomials ... to avoid inconsistencies. * Add docs * Add show_monomials * Export show_monomials and docs * Add start, next, done * Fix issues in sqrt! and derivative, and a test * Correct a typo in userguide.md [ci skip] * Fixed another typo [ci skip] * Fixes after review.
* Implement integrate for TaylorN variables with tests * Add docs for integrate, fix one case, and a test
* Add derivative method derivative(n,a) returns a Taylor1 variable; renamed existing derivative(n,a) method as derivativeval * Export derivativeval; add tests * Fix & add derivative tests * derivative(n,a) returns value; derivative(a,n) returns polynomial * Improve performance with in-place operations with suggestions by @lbenet * Fix docstrings * Fix tests for julia v0.7-DEV * Remove comment; add derivative test; add jacobian test for mixtures
* Add displayBigO to set/unset printing the bigO notation This commit also addresses some deprecation warnings for Julia 0.7. * Add docs [ci skip]
* Add rad2deg, deg2rad * Add tests * Add rad2deg!, deg2rad!, and tests
* Avoid irrelevant checks in getindex and setindex! * Simplify code and remove unused `zero_korder` and `order_posTb`
* Added matrix evaluation for Taylor1 and TaylorN. * Added tests for matrix evaluation. * Extended evaluation methods to include SubArrays. * Deleted redundant functions. * Updated Matrix evaluation tests. * extended norm and isapprox for AbstractSeries vectors. * Fixed problematic test
* Correct a truncation issue when factorization is possible * Small corrections and tests * Correct a problem with the bounds in sqrt! * Allow failures of nightly in travis
* Variable symbols * Fix symbols
* Variable symbols * Fix symbols * Fix tests, export new functions, and extend set_variable_names (JuliaDiff#152)
* Add derivative and integrate methods with symbols * Add evaluate for a TaylorN with a symbol and a value * Include symbols usage into the docs * Add two tests for Homogeneous polynomials * Add lookupvar and evaluate methods for Pair with tests
* Use `@doc doc"..."` * Use Compat, and update syntax for uninitialized arrays * Add packages of stdlib, and fix some tests * Replace Complex128, and load stdlib packages for tests * Use lastindex, update findfirst and lookupvar, and fix broadcasting * Instances related to Compat and broadcasting * Solve an issue in 0.6 related to endof * Fix endof for HomogeneousPolynomials * Further depraction warnings solved * Solve zero/one, rtoldefault and findfirst deprecations * Solve deprecations using convert methods as constructors
* Add methods of evaluate to handle NTuples * Extend evaluate with varargs. * Use zero./one. (instead of ugly fill!) * Fix a problem with evaluate and Pairs
* Fix promotion and conversion involving irrationals * Fix deprecations related to .= * Workaround Irrational/ AbstractIrrational * Add more tests
* Fix a deprecation (uninitialized -> undef) and an error in lookupvar * Fix findfirst predicate in lookupvar
* Type-stability fixes in ^ * Use iszero * Parameterize mutating functions * Fixes to few arithmetic mutable functions * Add more tests * Use sqr! in abs2! * Add more tests * Add findlast for Taylor1, with tests. * Fixes in a^n for a::Taylor1 and integer powers * Avoid computations in evaluate if coeff is zero * Add REQUIRE for documentation * Fixes in docs
* Add arbitrary partial derivatives of TaylorN * Add tests and docs * Add a new method of derivative, and use same convention as Taylor1's derivative * Add methods for getcoeff involving tuples
* Add methods of ^, that distinguish Real from AbstractFloat * Add one new test * Add tests involving intervals * Add test/REQUIRE and modify runtests.jl * Use ca^2 instead of ca*ca; important for Intervals * Fix tests * Fix (again) a broken test
Just rebased. I'll continue with this work. |
Did you rebased to current master? Some commits that are within this PR seem to me already merged... |
This is WIP for Nested Taylors, which I would like to benchmark eventually with
TaylorIntegration
's Jet Transport and compare it withTaylorN
performance for a number of variables. Currently, all basic operations fromarithmetic.jl
are working correctly, and do as a natural extension ofTaylor1
operations, butcalculus.jl
andother_functions.jl
need to be handled differently.To define
N
independent variables:Output is nothing near pretty for now, but one can check that basic operations work
Jet Transport for Nested Taylors can't be done yet as there isn't a well defined method for
norm(x,p)
wherex
is a Nested Taylor.All feedback is more than welcomed, @lbenet @PerezHz @dpsanders . No tests were added yet.
EDIT: I forgot to reference the corresponding discussion of #123