-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnr_routines.c
More file actions
39 lines (33 loc) · 767 Bytes
/
Copy pathnr_routines.c
File metadata and controls
39 lines (33 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string>
#include "nr_routines.h"
#include "HJM_type.h"
void nrerror(std::string error_text )
{
fprintf(stderr,"Numerical Recipes run-time error...\n");
fprintf(stderr,"%s\n",error_text.c_str());
fprintf(stderr,"...now exiting to system...\n");
exit(1);
}
FTYPE *dvector(long length) {
FTYPE *v = (FTYPE*)calloc(1, sizeof(FTYPE) * length);
if(!v) nrerror("allocation failure in dvector()");
return v;
}
void free_dvector(FTYPE *v)
{
free(v);
v = NULL;
}
FTYPE* dmatrix(long rows, long cols) {
FTYPE* m = (FTYPE *)calloc(1, sizeof(FTYPE) * rows * cols);
if(!m) nrerror("allocation failure in dmatrix()");
return m;
}
void free_dmatrix(FTYPE *m)
{
free(m);
m = NULL;
}