Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: aabf2b146e56
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2aaa0628a4cd
Choose a head ref

Commits on Mar 18, 2019

  1. hm

    eggrobin committed Mar 18, 2019
    Copy the full SHA
    8e16f15 View commit details
  2. add the files

    eggrobin committed Mar 18, 2019
    Copy the full SHA
    1c72c62 View commit details

Commits on Mar 19, 2019

  1. comparing implementations

    eggrobin committed Mar 19, 2019
    Copy the full SHA
    7e77966 View commit details

Commits on Mar 20, 2019

  1. multiple orders

    eggrobin committed Mar 20, 2019
    Copy the full SHA
    7bf1814 View commit details

Commits on Mar 21, 2019

  1. Copy the full SHA
    4566478 View commit details
  2. Copy the full SHA
    39a54a9 View commit details

Commits on Mar 22, 2019

  1. {

    eggrobin committed Mar 22, 2019
    Copy the full SHA
    0e1e75c View commit details
  2. 17

    eggrobin committed Mar 22, 2019
    Copy the full SHA
    d745b9e View commit details

Commits on Mar 24, 2019

  1. std::get

    eggrobin committed Mar 24, 2019
    Copy the full SHA
    6062117 View commit details

Commits on Mar 26, 2019

  1. Copy the full SHA
    6d5c0c2 View commit details

Commits on Mar 31, 2019

  1. remove constants

    eggrobin committed Mar 31, 2019
    Copy the full SHA
    2c29a6a View commit details

Commits on Apr 2, 2019

  1. Copy the full SHA
    2884f2c View commit details
  2. typos

    eggrobin committed Apr 2, 2019
    Copy the full SHA
    997a7e6 View commit details

Commits on Apr 4, 2019

  1. comments

    eggrobin committed Apr 4, 2019
    Copy the full SHA
    e3adb30 View commit details
  2. more comment bikeshedding

    eggrobin committed Apr 4, 2019
    Copy the full SHA
    ec0c075 View commit details

Commits on Apr 6, 2019

  1. test

    eggrobin committed Apr 6, 2019
    Copy the full SHA
    e2c3acf View commit details
  2. Copy the full SHA
    9105182 View commit details
  3. remove backward_differences

    eggrobin committed Apr 6, 2019
    Copy the full SHA
    40932e0 View commit details
  4. iwyu

    eggrobin committed Apr 6, 2019
    Copy the full SHA
    9dbec5a View commit details
  5. after pleroy's review

    eggrobin committed Apr 6, 2019
    Copy the full SHA
    9b3af9a View commit details
  6. Merge pull request #2123 from eggrobin/grgs

    Finite differences
    eggrobin authored Apr 6, 2019
    Copy the full SHA
    2aaa062 View commit details
33 changes: 0 additions & 33 deletions integrators/backward_difference.hpp

This file was deleted.

187 changes: 0 additions & 187 deletions integrators/backward_difference_body.hpp

This file was deleted.

2 changes: 0 additions & 2 deletions integrators/integrators.vcxproj
Original file line number Diff line number Diff line change
@@ -10,14 +10,12 @@
<ItemGroup>
<ClInclude Include="adams_moulton_integrator.hpp" />
<ClInclude Include="adams_moulton_integrator_body.hpp" />
<ClInclude Include="backward_difference_body.hpp" />
<ClInclude Include="cohen_hubbard_oesterwinter.hpp" />
<ClInclude Include="cohen_hubbard_oesterwinter_body.hpp" />
<ClInclude Include="embedded_explicit_generalized_runge_kutta_nyström_integrator.hpp" />
<ClInclude Include="embedded_explicit_generalized_runge_kutta_nyström_integrator_body.hpp" />
<ClInclude Include="embedded_explicit_runge_kutta_nyström_integrator.hpp" />
<ClInclude Include="embedded_explicit_runge_kutta_nyström_integrator_body.hpp" />
<ClInclude Include="backward_difference.hpp" />
<ClInclude Include="integrators.hpp" />
<ClInclude Include="integrators_body.hpp" />
<ClInclude Include="methods.hpp" />
6 changes: 0 additions & 6 deletions integrators/integrators.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -59,12 +59,6 @@
<ClInclude Include="mock_integrators.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="backward_difference.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="backward_difference_body.hpp">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="cohen_hubbard_oesterwinter_body.hpp">
<Filter>Source Files</Filter>
</ClInclude>
64 changes: 64 additions & 0 deletions mathematica/fornberg.wl
Original file line number Diff line number Diff line change
@@ -94,3 +94,67 @@ MapThread[{#1 #2,#2}&,{fornberg,commondenominators},2]

(* ::Input:: *)
(*GenerateSplitFornberg[1,14,0,#&,"Backwards"->True]*)


Clear[fornbergMatrix,fornbergDenominator,fornbergNumeratorMatrix];
fornbergMatrix[n_]:=fornbergMatrix[n]=Table[GenerateFornberg[1,n,j,#&][[2,n]],{j,0,n-1}];
fornbergDenominator[n_]:=fornbergDenominator[n]=If[Length[Union[#]]!=1,Throw[n->#],#[[1]]]&[ LCM@@Denominator[#]&/@fornbergMatrix[n]];
fornbergNumeratorMatrix[n_]:=fornbergNumeratorMatrix[n]=fornbergDenominator[n]fornbergMatrix[n];


SetDirectory[ParentDirectory[NotebookDirectory[]]];
Export[
"numerics\\finite_difference.mathematica.h",
With[
{\[ScriptCapitalN]=9},
"#pragma once
#include <array>
#include <tuple>
#include \"numerics/fixed_arrays.hpp\"
namespace principia {
namespace numerics {
namespace internal_finite_difference {
constexpr auto Numerators = std::make_tuple(\n "<>
StringRiffle[
Table[
"FixedMatrix<double, "<>
ToString[n]<>", "<>
ToString[n]<>">{{\n "<>
StringRiffle[
With[
{numberWidth=Table[
Max[StringLength@*ToString/@fornbergNumeratorMatrix[n][[;;,col]]],
{col,1,n}]},
StringRiffle[
Map[
StringRiffle[
Table[
StringPadLeft[
ToString[#[[col]]],
numberWidth[[col]]],
{col,1,n}],
", "]<>",\n"&,
fornbergNumeratorMatrix[n]],
" "]],
",\n "]<>" }}",
{n,1,\[ScriptCapitalN]}],
",\n "]<>");
constexpr std::array<double, "<>ToString[\[ScriptCapitalN]]<>"> Denominators{\n"<>
With[
{numberWidth=Max[StringLength@*ToString@*fornbergDenominator/@Range[\[ScriptCapitalN]]]},
StringJoin[
Table[
" "<>StringPadLeft[ToString[fornbergDenominator[n]],numberWidth]<>",\n",
{n,1,\[ScriptCapitalN]}]]]<>
"};
} // namespace principia
} // namespace numerics
} // namespace internal_finite_difference
"],
"text"]
37 changes: 37 additions & 0 deletions numerics/finite_difference.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#pragma once

#include <array>

#include "quantities/named_quantities.hpp"

namespace principia {
namespace numerics {
namespace internal_finite_difference {

using quantities::Derivative;
using quantities::Difference;

// Given n equally-spaced values f(xᵢ) = f(x₀ + i h),
// approximates the derivative f′(xⱼ) at xⱼ for j = |offset|, where 0 ≤ j < n.
// Special values of |offset| are:
// — |offset = 0|: forward difference;
// — |offset = (n - 1) / 2|, for odd n:
// central difference—in this case, the middle value is unused;
// — |offset = n - 1|: backward difference.
// The error on the derivative is 𝒪(hⁿ⁻¹) as h → 0.
// If f is a polynomial of degree less than or equal to n - 1, the result is
// exact up to rounding errors.
template<typename Value, typename Argument, int n>
Derivative<Value, Argument> FiniteDifference(
std::array<Value, n> const& values,
Argument const& step,
int offset);

} // namespace internal_finite_difference

using internal_finite_difference::FiniteDifference;

} // namespace numerics
} // namespace principia

#include "numerics/finite_difference_body.hpp"
Loading