Giter VIP home page Giter VIP logo

metaphysicl's People

Contributors

andrsd avatar bboutkov avatar dschwen avatar jwpeterson avatar lindsayad avatar roystgnr avatar rwcarlsen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

metaphysicl's Issues

add `.clang-format` config to the project

Could we please add a .clang-format config

DisableFormat: true
SortIncludes: Never

to the project (and to libmesh as well fro that matter). I tend to forget to turn off formatting when editing files in those projects (or later forget to turn it on again). Accidentally creating huge diffs, or upsetting Civet pre-check...

the (AD) derivative of the function **atan2**

Hi MetaPhysicL team,

is the (AD) derivative of the function atan2 not defined in "MetaPhysicL"?

If we use std::atan2(_grad_u_qp, _grad_u_qp) for the residual with an ADKernel in MOOSE , then we will have the error:

Linear solve did not converge due to DIVERGED_NANORINF iterations 0
Nonlinear solve did not converge due to DIVERGED_LINEAR_SOLVE iterations 0
Solve Did NOT Converge!
Finished Solving

Looks for the 'CL' library when OpenCL is a headers-only library

Failure:

configure:32789: c++ -std=gnu++17 -o conftest -O2 -pipe -fno-omit-frame-pointer -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -fno-omit-frame-pointer  -isystem /usr/local/include  -Wall -D_THREAD_SAFE -pthread  -fno-omit-frame-pointer -isystem /usr/local/include  conftest.cpp -lCL  -lm -L/usr/local/lib >&5
ld: error: unable to find library -lCL
c++: error: linker command failed with exit code 1 (use -v to see invocation)

OpenCL is a headers-only library.

Make check test failure with GCC 7.2

As mentioned via email this issue was spotted while I was investigating libMesh projection_matrix related issues and was forced to swap from GCC 6.x to 7.2.

Was getting errors on dualnamedarray.h:80 :
error: template argument ‘(unsigned int)derivativeindex’ involves template parameter(s)
struct DerivativeOf<NamedIndexArray<DataVector, SparseSizeVector>, derivativeindex>
when test/instantiations_unit.C and /test/dualnamedarray_unit.C were including the file.

At a cursory glance I can currently get by using the disable_dual_named branch without further complications, but this issue appparently needs to be addressed for later work. As a note, this issue may already have been addressed in C++17, but this needs to be verified once the official standard is available.

update_license.pl may not be working correctly?

Not sure what this script is or when it's supposed to run, but when running make distcheck in libmesh I get the following warnings (doesn't kill the build):

../../../../../../contrib/metaphysicl/0.2.0/src/common/lic_utils/update_license.pl ../../../../../../contrib/metaphysicl/0.2.0/LICENSE \
../../../../../../contrib/metaphysicl/0.2.0/test/*.C
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.compare_types_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.derivs_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.divgrad_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.dualnamedarray_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.dynamic_sparse_vector_navier_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.dynamic_sparse_vector_pde_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.identities_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.instantiations_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.main_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.namedindexarray_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.physics_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.shadow_dynamic_sparse_vector_navier_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.shadow_dynamic_sparse_vector_pde_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.shadow_sparse_struct_navier_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.shadow_sparse_struct_pde_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.shadow_sparse_vector_navier_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.shadow_sparse_vector_pde_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.shadow_vector_navier_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.shadow_vector_pde_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.sparse_derivs_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.sparse_identities_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.sparse_struct_navier_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.sparse_struct_pde_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.sparse_vector_navier_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.sparse_vector_pde_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.testheaders_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.testopt_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.vector_navier_unit.C.tmp) - aborting update.
[license_tool]: Warning -> unable to create tmp file locally (../../../../../../contrib/metaphysicl/0.2.0/test/.vector_pde_unit.C.tmp) - aborting update.

Explicit "= T()" constructions should zero-initialize data

#11 fixes this for NumberArray, as discussed in comments there, but previously (at least in the non-sparse NumberVector, if no other classes) I'd been trying to allow users to create uninitialized numeric objects intentionally and I hadn't realized the API could allow unintentionally uninitialized data as well.

Allow parallel reductions with ADReal

We need to be able to do parallel reductions like sum, min, max with ADReal type.

Currently, when we try to compile we would see:

/path/to/libmesh/installed/include/timpi/op_function.h:119:3: error: static_assert failed due to requirement 'opfunction_dependent_false<MetaPhysicL::DualNumber<double, MetaPhysicL::SemiDynamicSparseNumberArray<double, unsigned int, MetaPhysicL::NWrapper<50>>, true>>::value' "Only specializations of OpFunction may be used, did you forget to include a header file (e.g. parallel_algebra.h)?"
  static_assert(opfunction_dependent_false<T>::value,
  ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/path/to/libmesh/installed/include/timpi/parallel_implementation.h:2534:25: note: in instantiation of template class 'TIMPI::OpFunction<MetaPhysicL::DualNumber<double, MetaPhysicL::SemiDynamicSparseNumberArray<double, unsigned int, MetaPhysicL::NWrapper<50>>, true>>' requested here
                        OpFunction<T>::sum(),
                        ^
/path/to/thm/src/userobjects/ADVolumeJunctionBaseUserObject.C:123:17: note: in instantiation of function template specialization 'TIMPI::Communicator::sum<MetaPhysicL::DualNumber<double, MetaPhysicL::SemiDynamicSparseNumberArray<double, unsigned int, MetaPhysicL::NWrapper<50>>, true>>' requested here
  _communicator.sum(_residual[0]);
                ^

Tagging @roystgnr

Unused parameter warnings

In file included from ../src/systems/system_projection.C:29:
In file included from ../contrib/metaphysicl/0.2.0/src/numerics/include/metaphysicl/dynamicsparsenumberarray_decl.h:32:
In file included from ../contrib/metaphysicl/0.2.0/src/numerics/include/metaphysicl/dynamicsparsenumberbase_decl.h:39:
../contrib/metaphysicl/0.2.0/src/core/include/metaphysicl/ct_set.h:721:44: warning: unused parameter 'i' [-Wunused-parameter]
  static int runtime_value_of(unsigned int i) {
                                           ^
In file included from ../src/systems/system_projection.C:29:
In file included from ../contrib/metaphysicl/0.2.0/src/numerics/include/metaphysicl/dynamicsparsenumberarray_decl.h:32:
In file included from ../contrib/metaphysicl/0.2.0/src/numerics/include/metaphysicl/dynamicsparsenumberbase_decl.h:43:
../contrib/metaphysicl/0.2.0/src/utilities/include/metaphysicl/testable.h:111:70: warning: unused parameter 'rhs' [-Wunused-parameter]
  inline void operator==(const safe_bool<T>& lhs,const safe_bool<U>& rhs) {
                                                                     ^
../contrib/metaphysicl/0.2.0/src/utilities/include/metaphysicl/testable.h:116:70: warning: unused parameter 'rhs' [-Wunused-parameter]
  inline void operator!=(const safe_bool<T>& lhs,const safe_bool<U>& rhs) {
                                                                     ^
  CXX      src/systems/libmesh_dbg_la-system_subset_by_subdomain.lo
In file included from ../src/systems/system_projection.C:80:
../contrib/metaphysicl/0.2.0/src/numerics/include/metaphysicl/dynamicsparsenumberarray.h:75:76: warning: unused parameter 'a' [-Wunused-parameter]
DynamicSparseNumberArray<T,I>::dot (const DynamicSparseNumberArray<T2,I2>& a) const
                                                                           ^
../contrib/metaphysicl/0.2.0/src/numerics/include/metaphysicl/dynamicsparsenumberarray.h:94:86: warning: unused parameter 'a' [-Wunused-parameter]
DynamicSparseNumberArray<T,I>::outerproduct (const DynamicSparseNumberArray<T2, I2>& a) const
                                                                                     ^

No type named supertype

The following example

#include <Eigen/Dense>
#include "metaphysicl/dualnumber.h"

typedef double Real;
typedef MetaPhysicL::DualNumber<Real, Real> ADReal;
typedef Eigen::Matrix<ADReal, 2, 2> ADTensor;
typedef MetaPhysicL::DualNumber<ADReal, ADTensor> ADRealADTensor;

int
main(int argc, const char * argv[])
{
  ADReal x(1, 1);
  ADTensor I2{{1, 0}, {0, 1}};
  ADRealADTensor xx(x, I2);
  ADRealADTensor xx2 = xx + xx;
  return 0;
}

gives rise to the following compiler error:

/home/gary/.local/include/metaphysicl/compare_types.h: In instantiation of ‘struct MetaPhysicL::SymmetricPlusType<Eigen::Matrix<MetaPhysicL::DualNumber<double, double>, 2, 2>, Eigen::Matrix<MetaPhysicL::DualNumber<double, double>, 2, 2>, false, false>’:
/home/gary/.local/include/metaphysicl/dualnumber_decl.h:347:27:   required from ‘struct MetaPhysicL::PlusType<MetaPhysicL::DualNumber<MetaPhysicL::DualNumber<double, double>, Eigen::Matrix<MetaPhysicL::DualNumber<double, double>, 2, 2> >, MetaPhysicL::DualNumber<MetaPhysicL::DualNumber<double, double>, Eigen::Matrix<MetaPhysicL::DualNumber<double, double>, 2, 2> >, false, void>’
/home/gary/.local/include/metaphysicl/dualnumber.h:464:1:   required by substitution of ‘template<class T, class D, class T2, bool asd> typename MetaPhysicL::PlusType<MetaPhysicL::DualNumber<T, D, asd>, T2, false>::supertype MetaPhysicL::operator+(MetaPhysicL::DualNumber<T, D, asd>&&, const T2&) [with T = MetaPhysicL::DualNumber<double, double>; D = Eigen::Matrix<MetaPhysicL::DualNumber<double, double>, 2, 2>; T2 = MetaPhysicL::DualNumber<MetaPhysicL::DualNumber<double, double>, Eigen::Matrix<MetaPhysicL::DualNumber<double, double>, 2, 2> >; bool asd = false]’
main.C:36:29:   required from here
/home/gary/.local/include/metaphysicl/compare_types.h:486:63: error: no type named ‘supertype’ in ‘struct MetaPhysicL::PlusType<Eigen::Matrix<MetaPhysicL::DualNumber<double, double>, 2, 2>, Eigen::Matrix<MetaPhysicL::DualNumber<double, double>, 2, 2>, true, void>’
  486 |   typedef typename templatename<T,S,!reverseorder>::supertype supertype; \
      |                                                               ^~~~~~~~~
/home/gary/.local/include/metaphysicl/compare_types.h:492:1: note: in expansion of macro ‘Symmetric_definition’
  492 | Symmetric_definition(PlusType);
      | ^~~~~~~~~~~~~~~~~~~~

Failing std::pow instantiation

Instantiation of std::pow with a DualNumber base and an immediate double constant exponent fails with no matching function for call to 'if_else'

See long error below. (@lindsayad have you encountered this?

/Users/schwd/Programs/libmesh/installed/include/metaphysicl/dualnumber.h:415:795: error: no matching function for call to 'if_else'
template <typename T, typename D, typename T2, typename D2> inline typename CompareTypes<DualNumber<T,D>,DualNumber<T2,D2> >::supertype pow (const DualNumber<T,D>& a, const DualNumber<T2,D2>& b) { typedef typename CompareTypes<T,T2>::supertype TS; typedef typename CompareTypes<DualNumber<T,D>,DualNumber<T2,D2> >::supertype type; TS funcval = std::pow(a.value(), b.value()); return type(funcval, funcval * (b.value() * a.derivatives() / a.value() + MetaPhysicL::if_else(b.derivatives(), b.derivatives() * std::log(a.value()), b.derivatives()))); } template <typename T, typename D> inline DualNumber<T,D> pow (const DualNumber<T,D>& a, const DualNumber<T,D>& b) { T funcval = std::pow(a.value(), b.value()); return DualNumber<T,D>(funcval, funcval * (b.value() * a.derivatives() / a.value() + MetaPhysicL::if_else(b.derivatives(), b.derivatives() * std::log(a.value()), b.derivatives()))); } template <typename T, typename T2, typename D> inline typename CompareTypes<DualNumber<T2,D>,T,true>::supertype pow (const T& a, const DualNumber<T2,D>& b) { typedef typename CompareTypes<DualNumber<T2,D>,T,true>::supertype type; type newa(a); return std::pow(newa, b); } template <typename T, typename T2, typename D> inline typename CompareTypes<DualNumber<T,D>,T2>::supertype pow (const DualNumber<T,D>& a, const T2& b) { typedef typename CompareTypes<DualNumber<T,D>,T2>::supertype type; type newb(b); return std::pow(a, newb); }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ^~~~~~~~~~~~~~~~~~~~
/Users/schwd/Programs/libmesh/installed/include/metaphysicl/dualnumber.h:415:1412: note: in instantiation of function template specialization 'std::pow<double, MetaPhysicL::NumberArray<50, double> >' requested here
template <typename T, typename D, typename T2, typename D2> inline typename CompareTypes<DualNumber<T,D>,DualNumber<T2,D2> >::supertype pow (const DualNumber<T,D>& a, const DualNumber<T2,D2>& b) { typedef typename CompareTypes<T,T2>::supertype TS; typedef typename CompareTypes<DualNumber<T,D>,DualNumber<T2,D2> >::supertype type; TS funcval = std::pow(a.value(), b.value()); return type(funcval, funcval * (b.value() * a.derivatives() / a.value() + MetaPhysicL::if_else(b.derivatives(), b.derivatives() * std::log(a.value()), b.derivatives()))); } template <typename T, typename D> inline DualNumber<T,D> pow (const DualNumber<T,D>& a, const DualNumber<T,D>& b) { T funcval = std::pow(a.value(), b.value()); return DualNumber<T,D>(funcval, funcval * (b.value() * a.derivatives() / a.value() + MetaPhysicL::if_else(b.derivatives(), b.derivatives() * std::log(a.value()), b.derivatives()))); } template <typename T, typename T2, typename D> inline typename CompareTypes<DualNumber<T2,D>,T,true>::supertype pow (const T& a, const DualNumber<T2,D>& b) { typedef typename CompareTypes<DualNumber<T2,D>,T,true>::supertype type; type newa(a); return std::pow(newa, b); } template <typename T, typename T2, typename D> inline typename CompareTypes<DualNumber<T,D>,T2>::supertype pow (const DualNumber<T,D>& a, const T2& b) { typedef typename CompareTypes<DualNumber<T,D>,T2>::supertype type; type newb(b); return std::pow(a, newb); }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ^
/Users/schwd/Programs/moose/modules/tensor_mechanics/src/materials/ADComputeFiniteStrain.C:80:26: note: in instantiation of function template specialization 'std::pow<double, double, MetaPhysicL::NumberArray<50, double> >' requested here
      _Fhat[_qp] *= std::pow(ave_Fhat.det() / _Fhat[_qp].det(), 1.0 / 3.0);

Make std::complex<DualNumber> work

We're looking into using the Eigen library to obtain eigen decompositions of matrices of dual numbers. This is of course because LAPACK precludes us from using dual numbers entirely while Eigen is beautifully templated.

I seem to have hit a snag though as there are a bunch of functions used in <complex> that are not overloaded (or specialized) for dual numbers. This results in errors like

/Users/schwd/miniconda3/envs/moose/bin/../include/c++/v1/complex:685:15: error: no matching function for call to 'scalbn'
    _Tp __y = scalbn((__b * __c - __a * __d) / __denom, -__ilogbw);

and

/Users/schwd/miniconda3/envs/moose/bin/../include/c++/v1/complex:676:29: error: no matching function for call to 'fabs'
    _Tp __logbw = logb(fmax(fabs(__c), fabs(__d)));

NumberVector's data is not a vector?

@roystgnr I'm struggling to understand why NumberArray and NumberVector are essentially the same class, at least upon cursory glance at the class API. I guess I would have assumed that NumberVector would store its data in an std::vector but it's also a C array like for NumberArray. I'm curious about using something with std::vector for the underlying storage because then move operations become meaningful (although I may be venturing into the realm of micro-optimization). I know that DynamicSparseNumberBase uses std::vectors for both the data and indices.

Products of bootstrap in release tags?

@roystgnr What's your thought on committing configure and Makefile.in in release tags? I had some brief discussion with @jwpeterson this morning on the best way to include MetaPhysicL in libmesh, and having MetaPhysicL as a submodule with the hash corresponding to a release seems perhaps like a slight improvement over manually copying in releases. Including the boostrap generated files in the release would be essential for that to work (hence the failure of libMesh/libmesh#1845).

Continuing the tradition of copying in releases though is also fine... speaking of which, could we perhaps put out a new metaphysicl release that includes my new work?

divide dual number by long int throws an error

This will for example happen on certain architectures when dividing by the size of a std::vector. The "supertype" and CompareTypes stuff seems to be implemented for int but not long int.

std::min(a,b) vs std::min<DualReal>(a,b)

Why does

DualReal a=1, b=2;
std::min(a, b)

compile fine, but

DualReal a=1, b=2;
std::min<DualReal>(a, b)

gives an error: call to 'min' is ambiguous?! If anything the explicitly passed typename should make it less ambiguous. This is not a "for fun" question, but trips me up trying to instantiate a class from an external library, which has plenty of std:XXX<T>(...) type calls. Ping @lindsayad

P.S.: DualReal is the MetaPhysicL dual number type used in MOOSE

Everything is_convertible?

I'm not sure if this issue is related to #70 and #71. Even if they are related, I need to open this issue since #70 is now closed.
I get compile errors (after checking out #71) when trying to template Eigen over dual numbers. The minimal example would look like:

typedef double Real;
typedef MetaPhysicL::DualNumber<double, MetaPhysicL::DynamicSparseNumberArray<Real, unsigned int>>
    FirstDerivativeReal;
typedef MetaPhysicL::DualNumber<
    FirstDerivativeReal,
    MetaPhysicL::DynamicSparseNumberArray<FirstDerivativeReal, unsigned int>>
    ADReal;
typedef Eigen::Matrix<ADReal, 3, 3> ADRankTwoTensor;

std::cout << "std::is_convertible<ADRankTwoTensor, ADReal> == "
            << std::is_convertible<ADRankTwoTensor, ADReal>::value << '\n';

will output

std::is_convertible<ADRankTwoTensor, ADReal> == 1

which obviously causes issue when I multiply two ADRankTwoTensors -- it results in ambiguous overloading.

CompareTypes depending on reverseorder

@roystgnr we have this in compare_types:

// We can define CompareTypes template specializations with user types
// asymmetrically, to assist in disambiguation of templated functions
// or classes.  But sometimes we just need the supertype:

// FIXME: this won't work yet for cases where CompareTypes depends on
// reverseorder

I am curious what that comment really means? I am interested in going backwards and removing some of the decltypes in the return types of my NDDualNumber operations because they can result in value/derivative members with const and & specifiers which can mess-up down-stream type deductions. (A work-around is to apply std::remove_const and std::remove_reference, but I have started worrying about disambiguation of wrapper types as you discuss in libMesh/libmesh#1818)

If I go back to using return types based on CompareTypes, I run into the following problem when multiplying a NotADuckDualNumber tensor times a NotADuckDualNumber vector: the compiler considers this operator overload:

  template <typename T, typename T2, typename D>                                                   
  inline typename functorname##Type<NDDualNumber<T2, D>, T, true>::supertype operator opname(      
      const T & a, const NDDualNumber<T2, D> & b)                                                  
  {                                                                                                
    auto value = a opname b.value();                                                               
    auto derivatives = dn_second_calc;                                                             
    return {value, derivatives};                                                                   
  }                                                                                                

and it instantiates this MultipliesType with T2 corresponding to the vector and T corresponding to the NDDualNumber tensor. Because of the switch in order, this goes down the line all the way to attempting to instantiate a MultipliesType<VectorValue, TensorValue> which I haven't defined because it doesn't make mathematical sense (unless we transposed the vector). Thoughts on how we can avoid this compilation error? Hopefully my explanation made sense.

Improve DynamicSparseNumberFoo performance

The good news: we now have a working class that gives O(N_nonzero) instead of O(N) performance. This could be a big deal for https://github.com/libantioch/antioch sensitivity applications where our eventual N/N_nonzero will be ~1000.

The bad news: @friedmud reports that the current implementation has a constant performance overhead of ~1000. (based on profiling idaholab/moose#5661, and according to the profiler the cost is mostly from new/delete). He fixed the obvious flaws (pass-by-value to the sparsity operations) to little effect.

So let's brainstorm ideas. I'll sort what I've got so far by increasing level of difficulty IMHO:

PBR: Pass-by-reference in the sparsity operations (even if it's not a big win it's still better than nothing)

RI: Use reverse iteration to do in-place sparsity operations rather than creating temporary merged_foo vectors.

RV: Add C++11 rvalue operations so we can steal doomed input arguments' allocations where available.

CA: Give a custom allocator to the underlying std::vector.

CC: Replace std::vector with a custom container that keeps the first O(N_nonzero) elements on the stack and only hits the heap for larger cases.

ET: Use expression templates to postpone evaluations until we can do more of them at once without creating so many intermediate temporaries.

Make `DynamicStdArrayWrapper::_data` `protected`

I'd like to inherit from DynamicStdArrayWrapper to provide a drop in replacement for std::vector, to for example improve https://github.com/idaholab/moose/blob/c068d4e54568d8e83799c0c3de2328ae33c09dd4/framework/src/functions/PiecewiseMultilinear.C#L44-L47 (which uses local vectors with a size between 1 and 4). To replicate the zero initialization behavior (where std::array just does default initialization) the derived class needs access to the underlying _data.

Permit explicit cast to non-dual number

To make code that is templated on dual/non-dual more generic it'd be great if an explicit static_cast<double>(dual_number) was permitted. This would help with iostream output and cases where the derivatives can be dropped.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.