Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit cd21fa9

Browse files
bernhardbachmannOpenModelica-Hudson
authored andcommitted
Fix division by zero problem
1 parent 10a11a6 commit cd21fa9

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

SimulationRuntime/c/simulation/solver/nonlinearSolverHomotopy.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -613,23 +613,22 @@ void vecMultScaling(int n, double *a, double *b, double *c)
613613
{
614614
int i;
615615
for (i=0;i<n;i++)
616-
c[i] = a[i]*fabs(b[i]);
616+
c[i] = (fabs(b[i])>0 ? a[i]*fabs(b[i]):a[i]);
617617
}
618618

619619
void vecDivScaling(int n, double *a, double *b, double *c)
620620
{
621621
int i;
622622
for (i=0;i<n;i++)
623-
c[i] = a[i]/fabs(b[i]);
624-
// c[i] = a[i]/fmax(1.0,fabs(b[i]));
623+
c[i] = (fabs(b[i])>0 ? a[i]/fabs(b[i]):a[i]);
625624
}
626625

627626
void vecNormalize(int n, double *a, double *b)
628627
{
629628
int i;
630629
double norm = vec2Norm(n,a);
631630
for (i=0;i<n;i++)
632-
b[i] = a[i]/norm;
631+
b[i] = (norm>0 ? a[i]/norm:a[i]);
633632
}
634633

635634
void vecConst(int n, double value, double *a)

0 commit comments

Comments
 (0)