#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include "gm_rule.h"
Go to the source code of this file.
|
void | comp_next (int n, int k, int a[], int *more, int *h, int *t) |
|
void | gm_rule_set (int rule, int dim_num, int point_num, double w[], double x[]) |
|
int | gm_rule_size (int rule, int dim_num) |
|
int | i4_choose (int n, int k) |
|
int | i4_huge (void) |
|
int | i4_max (int i1, int i2) |
|
int | i4_min (int i1, int i2) |
|
int | i4_power (int i, int j) |
|
double * | monomial_value (int dim_num, int point_num, double x[], int expon[]) |
|
double | r8_abs (double x) |
|
double | r8_factorial (int n) |
|
double | r8vec_dot_product (int n, double a1[], double a2[]) |
|
double * | r8vec_uniform_01_new (int n, int *seed) |
|
double | simplex_unit_monomial_int (int dim_num, int expon[]) |
|
double | simplex_unit_monomial_quadrature (int dim_num, int expon[], int point_num, double x[], double w[]) |
|
double * | simplex_unit_sample (int dim_num, int n, int *seed) |
|
double * | simplex_unit_to_general (int dim_num, int point_num, double t[], double ref[]) |
|
double | simplex_unit_volume (int dim_num) |
|
void | timestamp (void) |
|
◆ TIME_SIZE
◆ comp_next()
void comp_next |
( |
int |
n, |
|
|
int |
k, |
|
|
int |
a[], |
|
|
int * |
more, |
|
|
int * |
h, |
|
|
int * |
t |
|
) |
| |
Definition at line 10 of file gm_rule.c.
128 for (
i = 1;
i <
k;
i++ )
146 *more = (
a[
k-1] !=
n );
◆ gm_rule_set()
void gm_rule_set |
( |
int |
rule, |
|
|
int |
dim_num, |
|
|
int |
point_num, |
|
|
double |
w[], |
|
|
double |
x[] |
|
) |
| |
Definition at line 152 of file gm_rule.c.
230 beta = (
int * ) malloc ( ( dim_num + 1 ) *
sizeof (
int ) );
232 for (
i = 0;
i <= s;
i++ )
234 weight = (
double ) one_pm;
238 for (
j = 1;
j <= j_hi;
j++ )
242 weight = weight * (
double ) (
j );
246 weight = weight * (
double ) (
d +
n - 2 *
i );
250 weight = weight / 2.0;
254 weight = weight / (
double ) (
j );
256 if (
j <=
d +
n -
i )
258 weight = weight / (
double ) (
j );
271 comp_next ( beta_sum, dim_num + 1, beta, &more, &
h, &
t );
274 for ( dim = 0; dim < dim_num; dim++ )
276 x[dim+
k*dim_num] = (
double ) ( 2 * beta[dim+1] + 1 )
◆ gm_rule_size()
int gm_rule_size |
( |
int |
rule, |
|
|
int |
dim_num |
|
) |
| |
Definition at line 294 of file gm_rule.c.
345 arg1 = dim_num + rule + 1;
◆ i4_choose()
int i4_choose |
( |
int |
n, |
|
|
int |
k |
|
) |
| |
Definition at line 353 of file gm_rule.c.
418 for (
i = 2;
i <= mn;
i++ )
420 value = ( value * ( mx +
i ) ) /
i;
◆ i4_huge()
Definition at line 428 of file gm_rule.c.
453 static int value = 2147483647;
◆ i4_max()
int i4_max |
( |
int |
i1, |
|
|
int |
i2 |
|
) |
| |
◆ i4_min()
int i4_min |
( |
int |
i1, |
|
|
int |
i2 |
|
) |
| |
◆ i4_power()
int i4_power |
( |
int |
i, |
|
|
int |
j |
|
) |
| |
Definition at line 541 of file gm_rule.c.
579 fprintf ( stderr,
"\n" );
580 fprintf ( stderr,
"I4_POWER - Fatal error!\n" );
581 fprintf ( stderr,
" I^J requested, with I = 0 and J negative.\n" );
593 fprintf ( stderr,
"\n" );
594 fprintf ( stderr,
"I4_POWER - Fatal error!\n" );
595 fprintf ( stderr,
" I^J requested, with I = 0 and J = 0.\n" );
610 for (
k = 1;
k <=
j;
k++ )
◆ monomial_value()
double* monomial_value |
( |
int |
dim_num, |
|
|
int |
point_num, |
|
|
double |
x[], |
|
|
int |
expon[] |
|
) |
| |
Definition at line 619 of file gm_rule.c.
667 value = (
double * ) malloc ( point_num *
sizeof (
double ) );
669 for ( point = 0; point < point_num; point++ )
674 for ( dim = 0; dim < dim_num; dim++ )
676 if ( 0 != expon[dim] )
678 for ( point = 0; point < point_num; point++ )
680 value[point] = value[point] * pow ( x[dim+point*dim_num], expon[dim] );
◆ r8_abs()
◆ r8_factorial()
◆ r8vec_dot_product()
◆ r8vec_uniform_01_new()
double* r8vec_uniform_01_new |
( |
int |
n, |
|
|
int * |
seed |
|
) |
| |
Definition at line 817 of file gm_rule.c.
892 fprintf ( stderr,
"\n" );
893 fprintf ( stderr,
"R8VEC_UNIFORM_01_NEW - Fatal error!\n" );
894 fprintf ( stderr,
" Input value of SEED = 0.\n" );
898 r = (
double * ) malloc (
n *
sizeof (
double ) );
900 for (
i = 0;
i <
n;
i++ )
904 *seed = 16807 * ( *seed -
k * 127773 ) -
k * 2836;
911 r[
i] = (
double ) ( *seed ) * 4.656612875E-10;
◆ simplex_unit_monomial_int()
double simplex_unit_monomial_int |
( |
int |
dim_num, |
|
|
int |
expon[] |
|
) |
| |
Definition at line 918 of file gm_rule.c.
967 for ( dim = 0; dim < dim_num; dim++ )
969 for (
i = 1;
i <= expon[dim];
i++ )
976 for ( dim = 0; dim < dim_num; dim++ )
979 value = value / (
double ) (
k );
◆ simplex_unit_monomial_quadrature()
double simplex_unit_monomial_quadrature |
( |
int |
dim_num, |
|
|
int |
expon[], |
|
|
int |
point_num, |
|
|
double |
x[], |
|
|
double |
w[] |
|
) |
| |
◆ simplex_unit_sample()
double* simplex_unit_sample |
( |
int |
dim_num, |
|
|
int |
n, |
|
|
int * |
seed |
|
) |
| |
Definition at line 1052 of file gm_rule.c.
1109 x = (
double * ) malloc ( dim_num *
n *
sizeof (
double ) );
1111 for (
j = 0;
j <
n;
j++ )
1115 for (
i = 0;
i <= dim_num;
i++ )
1117 e[
i] = -log ( e[
i] );
1121 for (
i = 0;
i <= dim_num;
i++ )
1123 total = total + e[
i];
1126 for (
i = 0;
i < dim_num;
i++ )
1128 x[
i+dim_num*
j] = e[
i] / total;
◆ simplex_unit_to_general()
Definition at line 1137 of file gm_rule.c.
1198 phy = (
double * ) malloc ( dim_num * point_num *
sizeof (
double ) );
1206 for ( point = 0; point < point_num; point++ )
1208 for ( dim = 0; dim < dim_num; dim++ )
1210 phy[dim+point*dim_num] =
t[dim+0*dim_num];
1212 for ( vertex = 1; vertex < dim_num + 1; vertex++ )
1214 phy[dim+point*dim_num] = phy[dim+point*dim_num]
1215 + (
t[dim+vertex*dim_num] -
t[dim+0*dim_num] ) * ref[vertex-1+point*dim_num];
◆ simplex_unit_volume()
double simplex_unit_volume |
( |
int |
dim_num | ) |
|
Definition at line 1224 of file gm_rule.c.
1259 for (
i = 1;
i <= dim_num;
i++ )
1261 volume = volume / ( (
double )
i );
◆ timestamp()
Definition at line 1268 of file gm_rule.c.
1297 # define TIME_SIZE 40
1300 const struct tm *tm;
1306 now = time ( NULL );
1307 tm = localtime ( &now );
1309 len = strftime ( time_buffer,
TIME_SIZE,
"%d %B %Y %I:%M:%S %p", tm );
1311 fprintf ( stdout,
"%s\n", time_buffer );