Skip to content
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
6c7d2ec
Started exploring what a test file would look like
osanstrong Aug 20, 2025
f3bf765
Merge branch 'celeritas-project:develop' into ferrari
osanstrong Aug 20, 2025
b6c3db4
Enumerated certain test cases for ferrari solver
osanstrong Aug 20, 2025
77c9964
Refined set of test case decsriptions, should be ready to actually de…
osanstrong Aug 20, 2025
db6f40b
Added harness class to FerrariSolver test, to hopefully streamline pr…
osanstrong Aug 20, 2025
feba8db
started adding tests using harness
osanstrong Aug 21, 2025
5776732
Added test cases for quartic solver and dominant cubic solver
osanstrong Aug 22, 2025
4b93605
Added Ferrari Solver
osanstrong Sep 23, 2025
483794c
Added ferrari test file to celeritas test lists
osanstrong Sep 23, 2025
261f9aa
Started fixing bugs in ferrari solver
osanstrong Sep 23, 2025
4f5ebeb
Added missing semicolon, comma
osanstrong Sep 23, 2025
f89b787
fixed syntax issues, added temporary debugging statements
osanstrong Sep 23, 2025
4affdce
fixed two flipped signs on test polynomials, and one which worked but…
osanstrong Sep 23, 2025
7a5f923
Added separate quadratic solver to also provide negative real roots, …
osanstrong Sep 23, 2025
a82f53d
Removed hacky print statements for debugging
osanstrong Sep 23, 2025
49504b1
corrected typo saying 'two solutions' to a quartic instead of four
osanstrong Oct 5, 2025
fa5d229
Generalized quartic solver harness and made ferrari solver test harne…
osanstrong Oct 5, 2025
7213cf8
Renamed FerrariSolver to QuarticSolver
osanstrong Oct 5, 2025
bbdf205
Merge branch 'celeritas-project:develop' into ferrari
osanstrong Oct 5, 2025
94c6673
Merge branch 'ferrari' of github.com:osanstrong/celeritas into ferrari
osanstrong Oct 5, 2025
9b56efe
Added precommit file format checks
osanstrong Oct 6, 2025
01cae24
Removed unused field for e/a
osanstrong Oct 6, 2025
bdcff63
Removed accidentally created/misnamed bcmake config file
osanstrong Oct 8, 2025
d567eb7
Switched special case equality/zero checks to use SoftZero instead of…
osanstrong Oct 20, 2025
7fba091
Removed redundant zero-e operator definition
osanstrong Oct 21, 2025
63918fd
Added citation for Algorithm 1010
osanstrong Oct 21, 2025
4079736
Renamed Roots2 alias to Real2 for consistency with other project files
osanstrong Oct 21, 2025
a7fbc4c
Moved logic for special biquadratic case to helper function
osanstrong Oct 21, 2025
d17c83b
Adjusted formatting of equations in documentation
osanstrong Oct 21, 2025
7540c6b
Removed unnecessary TODO statements
osanstrong Oct 21, 2025
2420744
Replaced self-square notation with ipow<2>
osanstrong Oct 21, 2025
0acf806
Replaced method to add in sorted list iwth method to add, and subsequ…
osanstrong Oct 21, 2025
f7bf2fa
Started adding typed testing to replace individually declared tests i…
osanstrong Oct 21, 2025
9f42f7e
Changed quartic unit tests to a templated test framework to use TYPED…
osanstrong Oct 21, 2025
1a4b6a2
Replaced cubic helper function tests with quartic tests which ensure …
osanstrong Oct 21, 2025
52e241c
Privatized helper functions in FerrariSolver
osanstrong Oct 21, 2025
dc23441
Added real_type wrappers to avoid potential double casting issues for…
osanstrong Oct 21, 2025
7b3b886
Cleaned up definition docstrings
osanstrong Oct 21, 2025
08f6a8e
Replaced manual lists of no_intersection() with lists of valid inters…
osanstrong Oct 21, 2025
9232367
Removed unused qb squared variable
osanstrong Oct 21, 2025
90f4eb6
Replaced x**n with x^n for readability
osanstrong Oct 21, 2025
0302df9
Updated docstrings for consistency
osanstrong Oct 22, 2025
21bc819
Fix manual placement indexing to work as described
osanstrong Oct 22, 2025
5cfa4e3
Added citation to Ferrari-Cardano method from mathematical handbook
osanstrong Nov 11, 2025
21edada
Removed odd spacing from equations
osanstrong Nov 11, 2025
624e2db
Refactored FerrariSolver to be constructed with tolerance and take ab…
osanstrong Nov 11, 2025
5c6dbdf
Renamed vague 'TestTypes' to specifically 'QuarticSolver' for clarity…
osanstrong Nov 11, 2025
6dd516f
Shifted certain unit tests which were moreso testing precision, chang…
osanstrong Nov 29, 2025
68d750a
Changed ferrari solver to use Numeric Recipes cubic solver to match A…
osanstrong Nov 29, 2025
0e54a60
Refactored FerrariSolver to use operator with option to specify surfa…
osanstrong Dec 1, 2025
a97c130
Refactored QuarticSolver test for clarity
osanstrong Dec 1, 2025
181397e
Made internal functions and tolerance member functions/data for each …
osanstrong Dec 3, 2025
957773e
Fix typo of description of surface three root test
osanstrong Dec 3, 2025
12c8c53
Fixed soft zero to be definitively constructed as member data
osanstrong Dec 4, 2025
00fa4d8
Removed unwise tolerance for cases near tangential intersections in s…
osanstrong Dec 4, 2025
de5dc0f
Nudged certain unit tests away from edges, where they were more actin…
osanstrong Dec 4, 2025
8ceafa7
Refactored if possible, or removed if not, surface unit tests which t…
osanstrong Dec 4, 2025
860902b
Removed Cardano from name of Ferrari solver, as it does not exclusive…
osanstrong Dec 5, 2025
21f6f86
Moved surface solution implementation to surface solution operator, a…
osanstrong Dec 5, 2025
dd90f38
Added expectation that a is not zero, as cubic special case makes e z…
osanstrong Dec 5, 2025
a7fe938
Removed sorting from FerrariSolver, added sorter to quartic tests for…
osanstrong Dec 5, 2025
cd455cc
Removed surface state argument in general solver case; expectation wi…
osanstrong Dec 5, 2025
1c5498f
Removed unused iostream include
osanstrong Dec 5, 2025
46d079b
Renamed UTIL section to HELPER FUNCTIONS
osanstrong Dec 5, 2025
dbef116
Removed separator between ININE DEFINITIONS section and the first fun…
osanstrong Dec 5, 2025
bc1272d
Moved separator bar to after TYPED_TEST_SUITE call
osanstrong Dec 5, 2025
c538234
Merge branch 'celeritas-project:develop' into ferrari
osanstrong Dec 5, 2025
e487c26
Merge remote-tracking branch 'upstream/develop' into ferrari
sethrj Dec 5, 2025
be90c5c
Remove orange specific code
sethrj Dec 5, 2025
4dd5fe3
Move quartic solver to corecel/math
sethrj Dec 5, 2025
535aa29
Add doc
sethrj Dec 5, 2025
3164480
Fix docs
sethrj Dec 5, 2025
58bf4c5
Revert "Fix docs"
sethrj Dec 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions scripts/cmake-presets/.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"version": 3,
"cmakeMinimumRequired": {"major": 3, "minor": 21, "patch": 0},
"configurePresets": [
{
"name": "dev",
"displayName": "Default development options",
"inherits": [".debug", "default"],
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": {"type": "BOOL", "value": "ON"},
"CMAKE_INSTALL_PREFIX": "${sourceDir}/install"
}
},
{
"name": "reldeb",
"displayName": "With vecgeom in optimized+errcheck mode",
"inherits": [".reldeb"],
"cacheVariables": {
"CELERITAS_BUILD_TESTS": {"type": "BOOL", "value": "ON"},
"CELERITAS_USE_VecGeom": {"type": "BOOL", "value": "ON"}
}
},
{
"name": "ndebug",
"displayName": "With vecgeom in optimized mode and CLHEP units",
"inherits": [".ndebug"],
"cacheVariables": {
"CELERITAS_BUILD_TESTS": {"type": "BOOL", "value": "OFF"},
"CELERITAS_UNITS": "CLHEP",
"CELERITAS_USE_VecGeom": {"type": "BOOL", "value": "ON"}
}
}
],
"buildPresets": [
{
"name": "dev",
"configurePreset": "dev",
"jobs": 8,
"nativeToolOptions": ["-k0"]
},
{"name": "reldeb", "configurePreset": "reldeb", "inherits": "dev"},
{"name": "ndebug", "configurePreset": "ndebug", "inherits": "dev"}
],
"testPresets": [
{
"name": "dev",
"configurePreset": "dev",
"output": {"outputOnFailure": true},
"execution": {"noTestsAction": "error", "stopOnFailure": false, "jobs": 8}
},
{"name": "reldeb", "configurePreset": "reldeb", "inherits": "dev"},
{"name": "ndebug", "configurePreset": "ndebug", "inherits": "dev"}
]
}
324 changes: 324 additions & 0 deletions src/orange/surf/detail/FerrariSolver.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,324 @@
//------------------------------- -*- C++ -*- -------------------------------//
// Copyright Celeritas contributors: see top-level COPYRIGHT file for details
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
//---------------------------------------------------------------------------//
//! \file orange/surf/detail/FerrariSolver.hh
//---------------------------------------------------------------------------//
#pragma once

#include <cmath>
#include <iostream>

#include "corecel/Types.hh"
#include "corecel/cont/Array.hh"
#include "corecel/math/Algorithms.hh"
#include "orange/OrangeTypes.hh"
#include "orange/surf/detail/QuadraticSolver.hh"

namespace celeritas
{
namespace detail
{
//---------------------------------------------------------------------------//
/*!
* Find positive, real, non-zero roots for quartic functions using the
* Ferrari-Cardano method.
*
* The quartic equation \f[
* a x^4 + b x^3 + c x^2 + d x + e = 0
* \f]
* has four solutions mathematically, but we only require solutions which are
* both real and positive. This equation is also subject to multiple cases of
* catastrophic precision-limitation-based error both fundamentally and as a
* consequence of the particular algorithm chosen. This solver implements the
* Ferrari-Cardano method, which is well-established and simple, but more
* prone to numerical error than contemporary methods to be explored such as
* Algorithm 1010.
*
* \return An Intersections array where each item is either a positive valid
* intersection or the sentinel result \c no_intersection().
*/
class FerrariSolver
{
public:
//!@{
//! \name Type aliases
using Intersections = Array<real_type, 4>;
using Roots2 = Array<real_type, 2>;
//!@}

// General case solve
static inline CELER_FUNCTION Intersections
solve_general(real_type a,
real_type b,
real_type c,
real_type d,
real_type e,
SurfaceState on_surface);

public:
// Construct w/ a, b, c, d
inline CELER_FUNCTION
FerrariSolver(real_type a, real_type b, real_type c, real_type d);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is consistent with QuadraticSolver, and I think this is fine. The other option would be:

FerrariSolver(Real3 abc, Real3 cde)

with a single operator() method.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our of curiosity, why this particular grouping? I had the impression putting e in operator(e)/operator() was a matter of declaring the particle was on the surface, but what's so special about putting abcde in two groups and picking c to be in both?

Copy link
Contributor

@elliottbiondo elliottbiondo Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this was my mistake. Take a look at SimpleQuadratic. The equation is:

ax^2 + by^2 + cz^2 + dx + ey + fz + g = 0

and the constructor takes

SimpleQuadric(Real3 const& abc, Real3 const& def, real_type g);

where abc and def are the second- and first-order terms, respectively, each set conveniently fitting into a Real3.

Looking at the quartic:

a x^4 + b x^3 + c x^2 + d x + e = 0

it can't be really split into Real3s too nicely (my mistake!). My new revised suggestion is:

class FerrariSolver
{
public:

    //! Input struct containing polynomial coefficents
    struct Coefficients
    {
         real_type a;
         real_type b;
         real_type c;
         real_type d;
         real_type d;
    }

    // Construct from coeffiecents
    inline CELER_FUNCTION  FerrariSoliver(Coefficients const& coeffs);

     // Solve for the roots
     inline CELER_FUNCTION Intersections operator()() const;
}

Basically, anytime you have more the 3-4 arguments, its usually preferred to make a input struct. Additionally, the only reason to supply e in the operator is if there is a use case where we set up a, b, c, and d, and the solve for the roots using multiple es. I am not sure if there is?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of a struct just use an Array<real_type, 5> coeff, so coeff[0] is the zeroth order terms, etc. You can locally expand it (maybe auto [a, b, c, d, e] = coeff; will work) for convenience.

And also I think that the QuadraticSolver's design may have also been deceiving; it tries to differentiate a major branch in the logic due to being degenerate or not. I think a better design would've been to have the "solver options/configuration" (aka min_a, tolerance) as the constructor arguments, and operator() takes the parameters.

So for your case, I would construct with a real_type tolerance that you use to build class data SoftZero soft_zero_. The operator() then would take Array<real_type, 5>.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could have an overload for Array<real_type, 4> for "on surface", but since you just treat "on surface" as "e=0" I don't see a big advantage in that case.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I prefer this; I just reorganized to the functor being constructed with a tolerance and passing all of abcde as the operator argument.

Though this does raise a couple of questions:

  • For the method manually specifying surface state, would it be better to have the method make a whole new array just to replace e with 0 so the original parameter is not modified (currently implemented but idk if this is bad for performance), or modify the original to avoid initializing a new array?
// Clone
CELER_FUNCTION auto FerrariSolver::solve_general(Real5 abcde,
                                                 SurfaceState on_surface,
                                                 real_type tolerance)
    -> Intersections
{
    FerrariSolver solve(tolerance);
    auto selected_abcde = abcde;
    if (on_surface == SurfaceState::on)
    {
        auto [a, b, c, d, e] = abcde;
        selected_abcde = {a, b, c, d, 0};
    }
    return solve(selected_abcde);
}
// Modify
CELER_FUNCTION auto FerrariSolver::solve_general(Real5 abcde,
                                                 SurfaceState on_surface,
                                                 real_type tolerance)
    -> Intersections
{
    FerrariSolver solve(tolerance);
    auto selected_abcde = abcde;
    if (on_surface == SurfaceState::on)
    {
        auto [a, b, c, d, e] = abcde;
        selected_abcde = {a, b, c, d, 0};
    }
    return solve(selected_abcde);
}
  • For that same method, it also uses a specified tolerance but this leads to both the method and the original constructor having a default tolerance argument; Is there a preferable way to to make this less redundant beyond just making a constant default_quartic_tolerance in the file? Or better to leave tinkering with this until actually implementing the Toroid surface where it'd actually be used?
  public:
    //!@{
    //! \name Type aliases
    using Intersections = Array<real_type, 4>;
    using Real2 = Array<real_type, 2>;
    using Real5 = Array<real_type, 5>;
    //!@}

    // Solve with manually specified surface state
    static inline CELER_FUNCTION Intersections solve_general(
        Real5 abcde,
        SurfaceState on_surface,
        real_type tolerance = Tolerance<real_type>::sqrt_quadratic());

  public:
    // Construct w/ given tolerance. Uses quadratic tolerance by default.
    inline CELER_FUNCTION
    FerrariSolver(real_type tolerance = Tolerance<real_type>::sqrt_quadratic());

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be better to have the method make a whole new array just to replace e with 0 so the original parameter is not modified (currently implemented but idk if this is bad for performance), or modify the original to avoid initializing a new array?

Your "clone" and "modify" code blocks are the same, but I think I know what you are asking. I think in this case it's fine to do this:

CELER_FUNCTION auto FerrariSolver::solve_general(
               Real5 coeffs,
               SurfaceState on_surface,
               real_type tolerance)
    -> Intersections
{
    FerrariSolver solve(tolerance);
    if (on_surface == SurfaceState::on)
    {
         coeffs.e = 0
    }
    return solve(coeffs);
}

Basically, upon passing coeffs to solve_general a copy is made, and any changes that are made to coeffs are done on the local copy only. If coeffs was a huge object, and we didn't want to make a copy, we could pass by reference via Real5& coeffs. The issue with this that any changes made to coeffs would also be reflected in the caller's coeffs. This is called a "side effect" and is generally not a good idea.

  1. It's not necessary for these functions to take default tolerances. That could actually introduces bugs, as we need the tolerances to be consistent throughout the code.


// Solver fully general case
inline CELER_FUNCTION Intersections operator()(real_type e) const;

// Solve degenerate / known surface case (e = 0)
inline CELER_FUNCTION Intersections operator()() const;

// Find dominant root of normalized cubic
static inline CELER_FUNCTION real_type
dominant_root_normalized_cubic(real_type b, real_type c, real_type d);

// Find real quadratic roots TODO: is there a way to use existing one?
static inline CELER_FUNCTION Roots2
real_roots_normalized_quadratic(real_type b, real_type c);

private:
//// DATA ////
real_type a_inv_; // 1/a
real_type ba_; // b/a
real_type ca_; // c/a
real_type da_; // d/a

//// UTIL ////
// Place real root in an ascending list
static inline CELER_FUNCTION void
place_root_sorted(Intersections& roots, real_type new_root);
};

//---------------------------------------------------------------------------//
// INLINE DEFINITIONS
//---------------------------------------------------------------------------//
/*!
* Find all positive roots for general quartic surfaces.
* Uses the Ferrari-Cardano algorithm.
*
* Currently, this is only used for toroids.
*/
CELER_FUNCTION auto FerrariSolver::solve_general(real_type a,
real_type b,
real_type c,
real_type d,
real_type e,
SurfaceState on_surface)
-> Intersections
{
FerrariSolver solve(a, b, c, d);
if (on_surface == SurfaceState::on)
{
return solve();
}
else
{
return solve(e);
}
}

//---------------------------------------------------------------------------//
/*!
* Default constructor with all five parameters a, b, c, d, and e.
*/
CELER_FUNCTION
FerrariSolver::FerrariSolver(real_type a, real_type b, real_type c, real_type d)
: a_inv_(1 / a), ba_(b * a_inv_), ca_(c * a_inv_), da_(d * a_inv_)
{
}

//---------------------------------------------------------------------------//
/*!
* Find all positive roots of x^4 + (b/a)x^3 + (c/a)x^2 + (d/a)x + (e/a) = 0
*
* Replaces negative or complex roots with no_intersection()
*/
CELER_FUNCTION auto FerrariSolver::operator()(real_type e) const
-> Intersections
{
real_type qb = 0.25 * ba_;
real_type qb2 = qb * qb;

// Incomplete quartic
real_type p = 3 * qb2 - 0.5 * ca_;
real_type q = 4 * qb * qb2 - ca_ * qb + 0.5 * da_;
real_type r = 3 * qb2 * qb2 - ca_ * qb2 + da_ * qb - (e * a_inv_);

// Final roots to return
Intersections roots(no_intersection(),
no_intersection(),
no_intersection(),
no_intersection());

// Edge case: equation is biquadratic TODO: need biquadratic tolerance
if (std::abs(q) <= 0)
{
// QuadraticSolver solve(1, -2*p);
// auto ir = solve(-r);
auto ir = real_roots_normalized_quadratic(-p, -r);
// QuadraticSolver puts real & >0 roots last
if (ir[1] != no_intersection() && ir[1] > 0)
{
real_type sqrt_ir1 = std::sqrt(ir[1]);
real_type from_pos1 = sqrt_ir1 - qb;
place_root_sorted(roots, from_pos1);
if (from_pos1 > 0)
{
place_root_sorted(roots, -sqrt_ir1 - qb);
}
}
if (ir[0] != no_intersection() && ir[0] > 0)
{
real_type sqrt_ir0 = std::sqrt(ir[0]);
real_type from_pos0 = sqrt_ir0 - qb;
place_root_sorted(roots, from_pos0);
if (from_pos0 > 0)
{
place_root_sorted(roots, -sqrt_ir0 - qb);
}
}
return roots;
}

// One real root of subsidiary cubic
real_type z0 = FerrariSolver::dominant_root_normalized_cubic(
p, r, p * r - 0.5 * q * q);

real_type s2 = 2 * p + 2 * z0;
if (s2 >= 0)
{
real_type s = std::sqrt(s2);
real_type t;
if (s == 0)
{ // TODO: Is there a tolerance where it makes more sense to use s=0?
t = z0 * z0 + r;
}
else
{
t = -q / s;
}
auto roots01 = real_roots_normalized_quadratic(s * 0.5, z0 + t);
auto roots23 = real_roots_normalized_quadratic(-s * 0.5, z0 - t);

place_root_sorted(roots, roots01[0] - qb);
place_root_sorted(roots, roots01[1] - qb);
place_root_sorted(roots, roots23[0] - qb);
place_root_sorted(roots, roots23[1] - qb);
}
return roots;
}

CELER_FUNCTION auto FerrariSolver::operator()() const -> Intersections
{
// TODO: Either find an optimization to make here, or remove this entirely
return operator()(0);
}

//---------------------------------------------------------------------------//
/*!
* Utility function which places the given real root into an intersection list
* in increasing order.
*
*/
CELER_FUNCTION void
FerrariSolver::place_root_sorted(Intersections& roots, real_type new_root)
{
if (new_root == no_intersection() || new_root <= 0)
{
return;
}
for (int i = 0; i < 4; i++)
{
if (roots[i] == no_intersection())
{
roots[i] = new_root;
break;
}
else if (new_root < roots[i])
{
for (int j = 3; j > i; j--)
{
roots[j] = roots[j - 1];
}
roots[i] = new_root;
break;
}
}
}

//---------------------------------------------------------------------------//
/*!
* Utility function which solves for the dominant root of a cubic function.
* Specifically, the cubic function \f[
* a x^3 + b x^2 + c x + d
* \f], where a is assumed to already be 1, and is not provided to the
* function.
*
* \return The dominant real root of the given cubic equation.
*/
CELER_FUNCTION real_type FerrariSolver::dominant_root_normalized_cubic(
real_type b, real_type c, real_type d)
{
real_type third = 1.0 / 3.0;
real_type third_b = b * third;
real_type ninth_b2 = third_b * third_b;

// Intermediate values
real_type f = third * c - ninth_b2;
real_type g = third_b * (2 * ninth_b2 - c) + d;
real_type h = 0.25 * g * g + f * f * f;

// degenerate case, NEEDS TOLERANCE FOR ZERO CHECK
if (f == 0 && g == 0 && h == 0)
{
return -1.0 * std::cbrt(d);
}
else if (h <= 0)
{
real_type j = std::sqrt(-f);
real_type k = std::acos(-0.5 * g / (j * j * j));
real_type m = std::cos(third * k);
return 2 * j * m - third_b;
}
else
{
real_type sqrt_h = std::sqrt(h);
real_type s = std::cbrt(-0.5 * g + sqrt_h);
real_type u = std::cbrt(-0.5 * g - sqrt_h);
return s + u - third_b;
}
}

//---------------------------------------------------------------------------//
/*!
* Utility function to return real roots of a quadratic function.
* Specifically, \f[
* a x^2 + (hb*2) x + c
* \f], where a is assumed to already be 1 and not provided.
*
* \return A pair of roots. If roots are imaginary, returns 2x
* no_intersection()
*/
CELER_FUNCTION auto
FerrariSolver::real_roots_normalized_quadratic(real_type hb, real_type c)
-> Roots2
{
real_type qb2 = ipow<2>(hb);
if (qb2 > c)
{
// Two real roots
real_type ht = std::sqrt(qb2 - c);
return Roots2(-hb - ht, -hb + ht);
}
else if (qb2 == c)
{
return Roots2(-hb, no_intersection());
}
else
{
return Roots2(no_intersection(), no_intersection());
}
}

//---------------------------------------------------------------------------//
} // namespace detail
} // namespace celeritas
1 change: 1 addition & 0 deletions test/orange/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ celeritas_add_device_test(surf/LocalSurfaceVisitor)

# Surface details
celeritas_add_test(surf/detail/QuadraticSolver.test.cc)
celeritas_add_test(surf/detail/QuarticSolver.test.cc)
celeritas_add_test(surf/detail/SurfaceTranslator.test.cc)
celeritas_add_test(surf/detail/SurfaceTransformer.test.cc)
celeritas_add_test(surf/detail/InvoluteSolver.test.cc)
Expand Down
Loading
Loading