Skip to content

Commit

Permalink
Utils -> UtilsLite
Browse files Browse the repository at this point in the history
  • Loading branch information
ebertolazzi committed Jun 10, 2024
1 parent 72f907c commit c37faf4
Show file tree
Hide file tree
Showing 49 changed files with 213 additions and 77 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "submodules/Utils"]
path = submodules/Utils
url = https://github.com/ebertolazzi/Utils.git
[submodule "submodules/quarticRootsFlocke"]
path = submodules/quarticRootsFlocke
url = https://github.com/ebertolazzi/quarticRootsFlocke.git
Expand All @@ -10,3 +7,6 @@
[submodule "cmake_utils"]
path = cmake_utils
url = https://github.com/ebertolazzi/cmake_utils.git
[submodule "submodules/UtilsLite"]
path = submodules/UtilsLite
url = [email protected]:ebertolazzi/UtilsLite.git
20 changes: 16 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,19 @@
cmake_minimum_required(VERSION 3.14)

project( Splines )
include(./cmake_utils/CMakeLists-common.txt)

if (IS_DIRECTORY "${PROJECT_SOURCE_DIR}/cmake_utils")
set( HOME "${PROJECT_SOURCE_DIR}/cmake_utils/" )
else()
if (IS_DIRECTORY "${PROJECT_SOURCE_DIR}/../cmake_utils")
set( HOME "${PROJECT_SOURCE_DIR}/../cmake_utils/" )
else()
set( HOME "${PROJECT_SOURCE_DIR}/../../cmake_utils/" )
endif()
endif()


include( "${HOME}/CMakeLists-common.txt" )

project(
${PROJECT_NAME}
Expand All @@ -26,8 +38,8 @@ if (APPLE)
set( CMAKE_OSX_ARCHITECTURES ${ARCHITECTURE} )
endif()

include(./cmake_utils/CMakeLists-cflags.txt)
include(./cmake_utils/CMakeLists-utilities.txt)
include( "${HOME}/CMakeLists-cflags.txt" )
include( "${HOME}/CMakeLists-utilities.txt" )

# Evaluating the suffix to append to target built by this CMake file
utils_artifacts_suffix(ARTIFACTS_STATIC_SUFFIX TRUE)
Expand Down Expand Up @@ -95,7 +107,7 @@ set(DEPEND_TARGETS)

# DEPENDENCIES (TRY TO USE ALREADY COMPILED SUBMODULE IN LARGE PROJECT)
utils_add_library_or_submodule( "quarticRootsFlocke" ROOTS )
utils_add_library_or_submodule( "Utils" UTILS )
utils_add_library_or_submodule( "UtilsLite" UTILS )
utils_add_library_or_submodule( "GenericContainer" GC "GC" )

message( STATUS "----------------------------------------------------------------" )
Expand Down
6 changes: 5 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
require_relative "./cmake_utils/Rakefile_common.rb"
if File.exist?(File.expand_path('./cmake_utils/Rakefile_common.rb', File.dirname(__FILE__))) then
require_relative "./cmake_utils/Rakefile_common.rb"
else
require_relative "../Rakefile_common.rb"
end

CLEAN.include ["./**/*.o", "./**/*.obj", "./bin/**/example*", "./build"]
CLEAN.clear_exclude.exclude { |fn| fn.pathmap("%f").downcase == "core" }
Expand Down
2 changes: 2 additions & 0 deletions src/SplineAkima.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
\*--------------------------------------------------------------------------*/

#include "Splines.hh"
#include "Utils_fmt.hh"

#include <cmath>

/**
Expand Down
2 changes: 2 additions & 0 deletions src/SplineAkima2D.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include "Splines.hh"
#include <cmath>
#include <iomanip>
#include "Utils_fmt.hh"

/**
*
*/
Expand Down
1 change: 1 addition & 0 deletions src/SplineBessel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
\*--------------------------------------------------------------------------*/

#include "Splines.hh"
#include "Utils_fmt.hh"

/*\
| ____ _ ____ _ _
Expand Down
9 changes: 9 additions & 0 deletions src/SplineBiCubic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
\*--------------------------------------------------------------------------*/

#include "Splines.hh"
#include "Utils_fmt.hh"

#include <cmath>
#include <iomanip>

Expand All @@ -37,6 +39,13 @@ namespace Splines {

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

BiCubicSplineBase::BiCubicSplineBase( string const & name )
: SplineSurf( name )
, m_mem_bicubic( fmt::format("BiCubicSplineBase[{}]",name) )
{}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

void
BiCubicSpline::make_spline() {
size_t nn{ size_t(m_nx*m_ny) };
Expand Down
2 changes: 2 additions & 0 deletions src/SplineBiQuintic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
\*--------------------------------------------------------------------------*/

#include "Splines.hh"
#include "Utils_fmt.hh"

#include <cmath>
#include <iomanip>

Expand Down
2 changes: 2 additions & 0 deletions src/SplineBilinear.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
\*--------------------------------------------------------------------------*/

#include "Splines.hh"
#include "Utils_fmt.hh"

#include <cmath>
#include <iomanip>

Expand Down
9 changes: 9 additions & 0 deletions src/SplineConstant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
\*--------------------------------------------------------------------------*/

#include "Splines.hh"
#include "Utils_fmt.hh"

#include <iomanip>

#ifdef __clang__
Expand All @@ -36,6 +38,13 @@ namespace Splines {

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

ConstantSpline::ConstantSpline( string const & name )
: Spline(name)
, m_mem_constant( fmt::format("ConstantSpline[{}]",name) )
{}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

void
ConstantSpline::reserve_external(
integer n,
Expand Down
1 change: 1 addition & 0 deletions src/SplineCubic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
\*--------------------------------------------------------------------------*/

#include "Splines.hh"
#include "Utils_fmt.hh"

#ifdef __clang__
#pragma clang diagnostic ignored "-Wc++98-compat"
Expand Down
9 changes: 9 additions & 0 deletions src/SplineCubicBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#include "Splines.hh"
#include "PolynomialRoots.hh"
#include "Utils_fmt.hh"

#include <iomanip>

#ifdef __clang__
Expand All @@ -36,6 +38,13 @@ namespace Splines {

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

CubicSplineBase::CubicSplineBase( string const & name )
: Spline(name)
, m_mem_cubic( fmt::format("CubicSplineBase[{}]::m_mem_cubic", name ) )
{}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

void
CubicSplineBase::build(
real_type const x[], integer incx,
Expand Down
1 change: 1 addition & 0 deletions src/SplineHermite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
\*--------------------------------------------------------------------------*/

#include "Splines.hh"
#include "Utils_fmt.hh"

#ifdef __clang__
#pragma clang diagnostic ignored "-Wc++98-compat"
Expand Down
19 changes: 19 additions & 0 deletions src/SplineLinear.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
\*--------------------------------------------------------------------------*/

#include "Splines.hh"
#include "Utils_fmt.hh"

#include <iomanip>

#ifdef __clang__
Expand All @@ -34,6 +36,17 @@ using namespace std; // load standard namspace

namespace Splines {

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

LinearSpline::LinearSpline( string const & name )
: Spline(name)
, m_mem_linear( fmt::format( "LinearSpline[{}]", name ) )
{
m_curve_extended_constant = true; // by default linear spline extend constant
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

real_type
LinearSpline::id_eval( integer i, real_type x ) const {
if ( m_curve_can_extend && m_curve_extended_constant ) {
Expand All @@ -44,13 +57,17 @@ namespace Splines {
return (1-s)*m_Y[i] + s * m_Y[i+1];
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

real_type
LinearSpline::eval( real_type x ) const {
std::pair<integer,real_type> res(0,x);
this->search( res );
return this->id_eval( res.first, res.second );
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

real_type
LinearSpline::id_D( integer i, real_type x ) const {
if ( m_curve_can_extend && m_curve_extended_constant ) {
Expand All @@ -59,6 +76,8 @@ namespace Splines {
return ( m_Y[i+1] - m_Y[i] ) / ( m_X[i+1] - m_X[i] );
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

real_type
LinearSpline::D( real_type x ) const {
if ( m_curve_can_extend && m_curve_extended_constant ) {
Expand Down
1 change: 1 addition & 0 deletions src/SplinePchip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "Splines.hh"
#include "SplinesUtils.hh"
#include "Utils_fmt.hh"

#include <cmath>

Expand Down
9 changes: 9 additions & 0 deletions src/SplineQuintic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#include "Splines.hh"
#include "SplinesUtils.hh"
#include "Utils_fmt.hh"

#include <cmath>

#ifdef __clang__
Expand All @@ -38,6 +40,13 @@ namespace Splines {

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

QuinticSplineBase::QuinticSplineBase( string const & name )
: Spline(name)
, m_base_quintic( fmt::format( "QuinticSplineBase[{}]", name ) )
{}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

/*\
Sistema lineare da risolvere
Expand Down
2 changes: 2 additions & 0 deletions src/SplineQuinticBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#include "Splines.hh"
#include "PolynomialRoots.hh"
#include "Utils_fmt.hh"

#include <iomanip>

#ifdef __clang__
Expand Down
1 change: 1 addition & 0 deletions src/SplineSet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "Splines.hh"
#include "SplinesUtils.hh"
#include "PolynomialRoots.hh"
#include "Utils_fmt.hh"

#include <limits>
#include <cmath>
Expand Down
2 changes: 2 additions & 0 deletions src/SplineSetGC.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
\*--------------------------------------------------------------------------*/

#include "Splines.hh"
#include "Utils_fmt.hh"

#include <limits>
#include <cmath>

Expand Down
2 changes: 2 additions & 0 deletions src/SplineVec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
\*--------------------------------------------------------------------------*/

#include "Splines.hh"
#include "Utils_fmt.hh"

#include <limits>
#include <cmath>

Expand Down
43 changes: 43 additions & 0 deletions src/Splines.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
\*--------------------------------------------------------------------------*/

#include "SplinesUtils.hh"
#include "Utils_fmt.hh"

#include <cmath>
#include <limits> // std::numeric_limits
Expand Down Expand Up @@ -479,6 +480,48 @@ namespace Splines {

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

void
Spline::y_min_max(
integer & i_min_pos,
real_type & x_min_pos,
real_type & y_min,
integer & i_max_pos,
real_type & x_max_pos,
real_type & y_max
) const {
i_min_pos = i_max_pos = 0;
x_min_pos = y_min = x_max_pos = y_max = 0;
UTILS_ERROR(
"In spline: {} y_min_max not implemented\n",
info()
);
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

void
Spline::y_min_max(
vector<integer> & i_min_pos,
vector<real_type> & x_min_pos,
vector<real_type> & y_min,
vector<integer> & i_max_pos,
vector<real_type> & x_max_pos,
vector<real_type> & y_max
) const {
i_min_pos.clear();
i_max_pos.clear();
x_min_pos.clear();
x_max_pos.clear();
y_min.clear();
y_max.clear();
UTILS_ERROR(
"In spline: {} y_min_max not implemented\n",
info()
);
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

real_type
curvature( real_type s, Spline const & X, Spline const & Y ) {
real_type x_1 = X.D(s);
Expand Down
Loading

0 comments on commit c37faf4

Please sign in to comment.