Skip to content

Commit

Permalink
Fixed memory allocation for stress.c. CRAN Release.
Browse files Browse the repository at this point in the history
  • Loading branch information
mhahsler committed Aug 19, 2024
1 parent cf3e22a commit bba46b9
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: seriation
Type: Package
Title: Infrastructure for Ordering Objects Using Seriation
Version: 1.5.6
Date: 2024-08-13
Date: 2024-08-19
Authors@R: c(
person("Michael", "Hahsler", role = c("aut", "cre", "cph"),
email = "mhahsler@lyle.smu.edu",
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# seriation 1.5.6 (08/13/2024)
# seriation 1.5.6 (08/19/2024)

## New Features
- Added registered_by field to registries.
Expand All @@ -7,6 +7,7 @@
- We replaced the FORTRAN implementation for BEA with code from package TSP.
- ME is now calculated using C code.
- optimal.c: updated memory allocation to R allocation.
- stress.c: updated memory allocation to R allocation.

## Bug Fixes
- Added two missing package anchors to palette man page.
Expand Down
2 changes: 1 addition & 1 deletion R/AAA_color_palette.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#' The two diverging palettes are: `bluered()` and `greenred()`.
#'
#' @name palette
#' @aliases palette, colors
#' @aliases palette colors
#' @family plots
#'
#' @param n number of different colors produces.
Expand Down
4 changes: 2 additions & 2 deletions R/AAA_seriation-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#' - Seriation: [seriate()], [criterion()], [get_order()], [permute()]
#' - Visualization: [pimage()], [bertinplot()], [hmap()], [dissplot()], [VAT()]
#'
#' @section Available seriation methods:
#' @section Available seriation methods and criteria:
#' * [A list with the implemented seriation methods](https://mhahsler.github.io/seriation/seriation_methods.html)
#' * [A visual comparison between seriation methods](https://mhahsler.github.io/seriation/visual_comparison.html)
#' * [A visual comparison between seriation methods](https://mhahsler.github.io/seriation/comparison.html)
#' * [A list with the implemented seriation criteria](https://mhahsler.github.io/seriation/seriation_criteria.html)
#'
#' @section Quickstart guides:
Expand Down
1 change: 0 additions & 1 deletion man/palette.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/seriation-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 22 additions & 22 deletions src/stress.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ SEXP stress(SEXP R_x, SEXP R_r, SEXP R_c, SEXP R_type)
* this sucks!
*/

r = Calloc(nr, int);
c = Calloc(nc, int);
r = R_Calloc(nr, int);
c = R_Calloc(nc, int);

/* copy and shift indexes */

Expand All @@ -187,12 +187,12 @@ SEXP stress(SEXP R_x, SEXP R_r, SEXP R_c, SEXP R_type)
[0] = stressNeumann(REAL(R_x), r, c, nr, nc, nrx);
break;
default:
Free(r);
Free(c);
R_Free(r);
R_Free(c);
error("stress: type not implemented");
}
Free(r);
Free(c);
R_Free(r);
R_Free(c);

/* UNPROTECT(3); */
UNPROTECT(1);
Expand Down Expand Up @@ -372,8 +372,8 @@ SEXP stress_dist(SEXP R_x, SEXP R_r, SEXP R_c, SEXP R_bycol, SEXP R_type)
* this sucks!
*/

r = Calloc(nr, int);
c = Calloc(nc, int);
r = R_Calloc(nr, int);
c = R_Calloc(nc, int);

/* copy and shift indexes */

Expand All @@ -388,7 +388,7 @@ SEXP stress_dist(SEXP R_x, SEXP R_r, SEXP R_c, SEXP R_bycol, SEXP R_type)
PROTECT(R_obj = NEW_NUMERIC(nr * (nr - 1) / 2));

d = REAL(R_obj);
t = Calloc(nr, double);
t = R_Calloc(nr, double);

switch (INTEGER(R_type)[0])
{
Expand All @@ -399,18 +399,18 @@ SEXP stress_dist(SEXP R_x, SEXP R_r, SEXP R_c, SEXP R_bycol, SEXP R_type)
distNeumann(REAL(R_x), r, c, nr, nc, nrx, 1, d, t);
break;
default:
Free(r);
Free(c);
Free(t);
R_Free(r);
R_Free(c);
R_Free(t);
error("stress_dist: \"type\" not implemented");
}
Free(t);
R_Free(t);
break;
case 1:
PROTECT(R_obj = NEW_NUMERIC(nc * (nc - 1) / 2));

d = REAL(R_obj);
t = Calloc(nc, double);
t = R_Calloc(nc, double);

switch (INTEGER(R_type)[0])
{
Expand All @@ -421,20 +421,20 @@ SEXP stress_dist(SEXP R_x, SEXP R_r, SEXP R_c, SEXP R_bycol, SEXP R_type)
distNeumann(REAL(R_x), c, r, nc, nr, 1, nrx, d, t);
break;
default:
Free(r);
Free(c);
Free(t);
R_Free(r);
R_Free(c);
R_Free(t);
error("stress_dist: type not implemented");
}
Free(t);
R_Free(t);
break;
default:
Free(r);
Free(c);
R_Free(r);
R_Free(c);
error("stress_dist: \"bycol\" invalid");
}
Free(r);
Free(c);
R_Free(r);
R_Free(c);

/* UNPROTECT(3); */
UNPROTECT(1);
Expand Down

0 comments on commit bba46b9

Please sign in to comment.