Skip to content

Conversation

@abhinavsns
Copy link
Member

Allowing for petsc to work in float and double both

Copy link
Contributor

@syaskovets syaskovets left a comment

Choose a reason for hiding this comment

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

Which use case problem does it solve? In this implementation the point expression and the other operand T d either have the same type, or the type of the operand is implicitly converted to double (which works for all base types). I don't see why it has to be compared with float here

@abhinavsns
Copy link
Member Author

Which use case problem does it solve? In this implementation the point expression and the other operand T d either have the same type, or the type of the operand is implicitly converted to double (which works for all base types). I don't see why it has to be compared with float here

The Dcpse class uses point expressions which ambiguously match for the division operator to both cases when the type is Float, resulting in compilation failure when compiling float versions.

@abhinavsns abhinavsns added the bug Something isn't working label Sep 26, 2024
@syaskovets
Copy link
Contributor

Could you please provide a reproducible example? I would like to understand the issue and fix it for all point_expression_op's. For now it seems adding typename check=typename std::enable_if<std::is_same<T,double>::value >::type to the other operator point_expression_op of the same kind should be a more straightforward solution

@abhinavsns
Copy link
Member Author

abhinavsns commented Oct 7, 2024

typedef float float_type;
float_type eps=1;
Point<3, float_type> xq = {1,2,3},xp={4,5,6};
Point<3, float_type> normalizedArg = (xp - xq) / eps;

Compiling the above results in:

error: use of overloaded operator '/' is ambiguous (with operand types 'point_expression_op<Point<3U, float>, Point<3U, float>, Point<3U, float>, 2>' and 'float_type' (aka 'float'))
  577 |         Point<3, float_type> normalizedArg = (xp - xq) / eps;
      |                                              ~~~~~~~~~ ^ ~~~
openfpm_data/src/Space/Shape/Point_operators.hpp:1199:23: note: candidate function [with orig = Point<3, float>, exp1 = Point<3, float>, exp2 = Point<3, float>, op1 = 2, T = float]
 1199 | CREATE_POINT_OPERATOR(operator/,POINT_DIV)
      |                       ^
openfpm_data/src/Space/Shape/Point_operators.hpp:1199:23: note: candidate function [with orig = Point<3, float>, exp1 = Point<3, float>, exp2 = Point<3, float>, op1 = 2, T = float, check = void]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants