}
} else {
for (j = ia[i]; j < ia[i + 1]; j++) {
- if (val) color[j] = ABS(val[j]);
+ if (val) color[j] = fabs(val[j]);
else color[j] = 1;
if (i != ja[j]) {
if (first) {
* Contributors: See CVS logs. Details at http://www.graphviz.org/
*************************************************************************/
#include "general.h"
+#include <math.h>
#include "time.h"
#include "SparseMatrix.h"
#include "node_distinct_coloring.h"
for (i = 0; i < ns1 - 1; i++){
for (j = 0; j < ns2 - 1; j++){
cos_a = intersection_angle(&(x1[dim*i]), &(x1[dim*(i + 1)]), &(x2[dim*j]), &(x2[dim*(j+1)]));
- if (!check_edges_with_same_endpoint && cos_a >= -1) cos_a = ABS(cos_a);
+ if (!check_edges_with_same_endpoint && cos_a >= -1) cos_a = fabs(cos_a);
if (cos_a > cos_critical) {
return 1;
}
for (j = i+1; j < nz2; j++){
u2 = irn[j]; v2 = jcn[j];
cos_a = intersection_angle(&(x[dim*u1]), &(x[dim*v1]), &(x[dim*u2]), &(x[dim*v2]));
- if (!check_edges_with_same_endpoint && cos_a >= -1) cos_a = ABS(cos_a);
+ if (!check_edges_with_same_endpoint && cos_a >= -1) cos_a = fabs(cos_a);
if (cos_a > cos_critical) {
B = SparseMatrix_coordinate_form_add_entries(B, 1, &i, &j, &cos_a);
}
* Contributors: See CVS logs. Details at http://www.graphviz.org/
*************************************************************************/
#include "general.h"
+#include <math.h>
static real cross(real *u, real *v){
return u[0]*v[1] - u[1]*v[0];
snorm = sqrt(snorm);
b = cross(r, s);
line_dist_close = (line_segments_distance(p1, p2, q1, q2) <= close*MAX(rnorm, snorm));
- if (ABS(b) <= epsilon*snorm*rnorm){/* parallel */
+ if (fabs(b) <= epsilon*snorm*rnorm){/* parallel */
if (line_dist_close) {/* two parallel lines that are close */
return 1;
}
}
/* normal case of intersect or very close */
- return ABS(res);
+ return fabs(res);
}
return -2;/* no intersection, and lines are not even close */
}
#include "types.h"
#include "globals.h"
#include "general.h"
+#include <math.h>
#include "time.h"
#include "SparseMatrix.h"
#include "vector.h"
if (Verbose > 1) fprintf(stderr,"level %d->%d, edges %d -> %d, ink %f->%f , gain = %f, or %f\n", grid->level, cgrid->level, grid->n,
cgrid->n, grid->total_ink, grand_total_ink, grid->total_ink - grand_total_ink, grand_total_gain);
- assert(ABS(grid->total_ink - cgrid->total_ink - grand_total_gain) <= 0.0001*grid->total_ink);
+ assert(fabs(grid->total_ink - cgrid->total_ink - grand_total_gain) <= 0.0001*grid->total_ink);
cgrid = Agglomerative_Ink_Bundling_establish(cgrid, pick, angle_param, angle);
grid->next = cgrid;
if (Verbose > 1) fprintf(stderr,"level %d->%d, edges %d -> %d, ink %f->%f , gain = %f, or %f\n", grid->level, cgrid->level, grid->n,
cgrid->n, grid->total_ink, grand_total_ink, grid->total_ink - grand_total_ink, grand_total_gain);
- assert(ABS(grid->total_ink - cgrid->total_ink - grand_total_gain) <= 0.0001*grid->total_ink);
+ assert(fabs(grid->total_ink - cgrid->total_ink - grand_total_gain) <= 0.0001*grid->total_ink);
cgrid = Agglomerative_Ink_Bundling_aggressive_establish(cgrid, pick, angle_param, angle);
grid->next = cgrid;
if (Verbose && DEBUG) fprintf(stderr,"calling ink2...\n");
ink1 = ink(edges, ia[i+1]-ia[i], pick, &ink0, &meet1, &meet2, angle_param, angle);
if (Verbose && DEBUG) fprintf(stderr,"finish calling ink2...\n");
- assert(ABS(ink1 - cgrid->inks[i])<=MAX(TOL, TOL*ink1) && ink1 - ink0 <= TOL);
+ assert(fabs(ink1 - cgrid->inks[i])<=MAX(TOL, TOL*ink1) && ink1 - ink0 <= TOL);
wgt_all = 0.;
if (ia[i+1]-ia[i] > 1){
for (j = ia[i]; j < ia[i+1]; j++){
if (Verbose && DEBUG) fprintf(stderr,"calling ink3...\n");
ink1 = ink(edges, ia[i+1]-ia[i], pick, &ink0, &meet1, &meet2, angle_param, angle);
if (Verbose && DEBUG) fprintf(stderr,"done calling ink3...\n");
- assert(ABS(ink1 - cgrid->inks[i])<=MAX(TOL, TOL*ink1) && ink1 - ink0 <= TOL);
+ assert(fabs(ink1 - cgrid->inks[i])<=MAX(TOL, TOL*ink1) && ink1 - ink0 <= TOL);
xx[i*4 + 0] = meet1.x;
xx[i*4 + 1] = meet1.y;
xx[i*4 + 2] = meet2.x;
#include "types.h"
#include "globals.h"
#include "general.h"
+#include <math.h>
#include "SparseMatrix.h"
#include "edge_bundling.h"
#include <time.h>
ca = 0;
for (i = 0; i < dim; i++)
ca += (v1[i]-u1[i])*(v2[i]-u2[i]);
- ca = ABS(ca/(len1*len2));
+ ca = fabs(ca/(len1*len2));
assert(ca > -0.001);
/* scale compatibility */
return edges;
}
-static real absfun(real x){
- return ABS(x);
-}
-
-
-
-
static pedge* modularity_ink_bundling(int dim, int ne, SparseMatrix B, pedge* edges, real angle_param, real angle){
int *assignment = NULL, flag, nclusters;
real modularity;
/* B may contain negative entries */
BB = SparseMatrix_copy(B);
- BB = SparseMatrix_apply_fun(BB, absfun);
+ BB = SparseMatrix_apply_fun(BB, fabs);
modularity_clustering(BB, TRUE, 0, use_value_for_clustering, &nclusters, &assignment, &modularity, &flag);
SparseMatrix_delete(BB);
fprintf(stderr,"compatibility=%f\n",dist);
*/
- if (ABS(dist) > tol){
+ if (fabs(dist) > tol){
B = SparseMatrix_coordinate_form_add_entries(B, 1, &i, &jj, &dist);
B = SparseMatrix_coordinate_form_add_entries(B, 1, &jj, &i, &dist);
}
#include "call_tri.h"
#include "red_black_tree.h"
#include "types.h"
+#include <math.h>
#include "memory.h"
#include "globals.h"
#include <time.h>
jj = ja[j];
if (jj == i) continue;
dist = distance(x, dim, i, jj);
- dx = ABS(x[i*dim] - x[jj*dim]);
- dy = ABS(x[i*dim+1] - x[jj*dim+1]);
+ dx = fabs(x[i*dim] - x[jj*dim]);
+ dy = fabs(x[i*dim+1] - x[jj*dim+1]);
wx = width[i*dim]+width[jj*dim];
wy = width[i*dim+1]+width[jj*dim+1];
if (dx < MACHINEACC*wx && dy < MACHINEACC*wy){
fprintf(stderr," predecessor is node %d y = %f\n", ((scan_point *)newNode->key)->node, ((scan_point *)newNode->key)->x);
#endif
if (neighbor != k){
- if (ABS(0.5*(bsta+bsto) - 0.5*(bbsta+bbsto)) < 0.5*(bsto-bsta) + 0.5*(bbsto-bbsta)){/* if the distance of the centers of the interval is less than sum of width, we have overlap */
+ if (fabs(0.5*(bsta+bsto) - 0.5*(bbsta+bbsto)) < 0.5*(bsto-bsta) + 0.5*(bbsto-bbsta)){/* if the distance of the centers of the interval is less than sum of width, we have overlap */
A = SparseMatrix_coordinate_form_add_entries(A, 1, &neighbor, &k, &one);
#ifdef DEBUG_RBTREE
fprintf(stderr,"====================================== %d %d\n",k,neighbor);
for (i = 0; i < m; i++){
diag[i] = 1./(m-1);
for (j = ia[i]; j < ia[i+1]; j++){
- if (i == ja[j] && ABS(a[j]) > 0) diag[i] = 1./((m-1)*alpha+a[j]);
+ if (i == ja[j] && fabs(a[j]) > 0) diag[i] = 1./((m-1)*alpha+a[j]);
}
}
for (i = 0; i < m; i++){
diag[i] = 1.;
for (j = ia[i]; j < ia[i+1]; j++){
- if (i == ja[j] && ABS(a[j]) > 0) diag[i] = 1./a[j];
+ if (i == ja[j] && fabs(a[j]) > 0) diag[i] = 1./a[j];
}
}
for (k = 0; k < 2; k++){
y[k] = x[j*dim+k] - x[i*dim+k];
}
- if (ABS(y[0]) <= ABS(y[1])*eps){
+ if (fabs(y[0]) <= fabs(y[1])*eps){
if (y[1] > 0) return 0.5*PI;
return 1.5*PI;
}
*************************************************************************/
#include "general.h"
+#include <math.h>
#include "SparseMatrix.h"
#include "spring_electrical.h"
#include "post_process.h"
for (j = ia[i]; j < ia[i+1]; j++){
k = ja[j];
if (k != i){
- dist = MAX(ABS(a[j]), epsilon);
+ dist = MAX(fabs(a[j]), epsilon);
jd[nz] = jw[nz] = k;
w[nz] = -1/(dist*dist);
w[nz] = -1.;
/* make sure x is not all at the same point */
for (i = 1; i < n; i++){
for (k = 0; k < dim; k++) {
- if (ABS(x[0*dim+k] - x[i*dim+k]) > MACHINEACC){
+ if (fabs(x[0*dim+k] - x[i*dim+k]) > MACHINEACC){
samepoint = FALSE;
i = n;
break;
#include "general.h"
#include "DotIO.h"
#include "clustering.h"
+#include <math.h>
#include "mq.h"
/* #include "spring_electrical.h" */
#include "color_palette.h"
}
} else {
for (j = ia[i]; j < ia[i+1]; j++) {
- color[j] = ABS(val[j]);
+ color[j] = fabs(val[j]);
if (i != ja[j]){
if (first){
mindist = color[j];
if (mask[jb[j]] < ia[i]) goto RETURN;
}
for (j = ib[i]; j < ib[i+1]; j++){
- if (ABS(b[j] - a[mask[jb[j]]]) > SYMMETRY_EPSILON) goto RETURN;
+ if (fabs(b[j] - a[mask[jb[j]]]) > SYMMETRY_EPSILON) goto RETURN;
}
}
res = TRUE;
if (mask[jb[j]] < ia[i]) goto RETURN;
}
for (j = ib[i]; j < ib[i+1]; j++){
- if (ABS(b[2*j] - a[2*mask[jb[j]]]) > SYMMETRY_EPSILON) goto RETURN;
- if (ABS(b[2*j+1] - a[2*mask[jb[j]]+1]) > SYMMETRY_EPSILON) goto RETURN;
+ if (fabs(b[2*j] - a[2*mask[jb[j]]]) > SYMMETRY_EPSILON) goto RETURN;
+ if (fabs(b[2*j+1] - a[2*mask[jb[j]]+1]) > SYMMETRY_EPSILON) goto RETURN;
}
}
res = TRUE;
for (i = 0; i < A->m; i++){
max = 0;
for (j = A->ia[i]; j < A->ia[i+1]; j++){
- max = MAX(ABS(a[j]), max);
+ max = MAX(fabs(a[j]), max);
}
if (max != 0){
for (j = A->ia[i]; j < A->ia[i+1]; j++){
real *a = (real*) A->a;
for (i = 0; i < A->m; i++){
for (j = sta; j < ia[i+1]; j++){
- if (ABS(a[j]) > epsilon){
+ if (fabs(a[j]) > epsilon){
ja[nz] = ja[j];
a[nz++] = a[j];
}
int *a = (int*) A->a;
for (i = 0; i < A->m; i++){
for (j = sta; j < ia[i+1]; j++){
- if (ABS(a[j]) > epsilon){
+ if (fabs(a[j]) > epsilon){
ja[nz] = ja[j];
a[nz++] = a[j];
}
if (heap_id == UNVISITED){
ndata = MALLOC(sizeof(struct nodedata_struct));
- ndata->dist = ABS(a[j]) + ndata_min->dist;
+ ndata->dist = fabs(a[j]) + ndata_min->dist;
ndata->id = jj;
heap_ids[jj] = BinaryHeap_insert(h, ndata);
//fprintf(stderr," set neighbor id=%d, dist=%f, hid = %d, a[%d]=%f, dist=%f\n",jj, ndata->dist, heap_ids[jj], jj, a[j], ndata->dist);
} else {
ndata = BinaryHeap_get_item(h, heap_id);
- ndata->dist = MIN(ndata->dist, ABS(a[j]) + ndata_min->dist);
+ ndata->dist = MIN(ndata->dist, fabs(a[j]) + ndata_min->dist);
assert(ndata->id == jj);
BinaryHeap_reset(h, heap_id, ndata);
//fprintf(stderr," reset neighbor id=%d, dist=%f, hid = %d, a[%d]=%f, dist=%f\n",jj, ndata->dist,heap_id, jj, a[j], ndata->dist);
} while (dist_max > dist0);
*connectedQ = (!flag);
- assert((dist_max - dist0)/MAX(1, MAX(ABS(dist0), ABS(dist_max))) < 1.e-10);
+ assert((dist_max - dist0)/MAX(1, MAX(fabs(dist0), fabs(dist_max))) < 1.e-10);
*end1 = root;
*end2 = list[nlist-1];
for (i = 0; i < n; i++){
for (j = ia[i]; j < ia[i+1]; j++){
if (ja[j] == i) continue;
- diag[i] += ABS(a[j]);
+ diag[i] += fabs(a[j]);
}
}
} else {
*/
res = 0;
- for (i = 0; i < n; i++) res += ABS(x[i] - y[i]);
+ for (i = 0; i < n; i++) res += fabs(x[i] - y[i]);
if (Verbose) fprintf(stderr,"page rank iter -- %d, res = %f\n",iter, res);
memcpy(x, y, sizeof(real)*n);
} while (res > epsilon);