Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
abetusk committed May 10, 2024
1 parent 0c5c7c0 commit 2f65d6e
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 1 deletion.
3 changes: 2 additions & 1 deletion wiki/src/littlewood-run
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
#

export D=11
export M=1000

if [[ "$1" != "" ]] ; then
export D="$1"
fi

gcc -O3 littlewoodp.c -o littlewoodp
#./littlewoodp $D | xargs -n1 -I{} mpsolve -p '{}' | tr -d '(),' | sort -u > lwp-d$D.gp
./littlewoodp $D | xargs -n1 -I{} mpsolve -p '{}' | tr -d '(),' > lwp-d$D.gp
./littlewoodp $D $M | xargs -n1 -I{} mpsolve -p '{}' | tr -d '(),' > lwp-d$D.gp
cat lwp-d$D.gp | ./clog.py > ln_lwp-d$D.gp
22 changes: 22 additions & 0 deletions wiki/src/randpoly-run
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
#
# License: CC0
#
# To the extent possible under law, the person who associated CC0 with
# this project has waived all copyright and related or neighboring rights
# to this project.
#
# You should have received a copy of the CC0 legalcode along with this
# work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
#

export D=32
export M=500

if [[ "$1" != "" ]] ; then
export D="$1"
fi

gcc -O3 randpoly.c -o randpoly
./randpoly $D $M | xargs -n1 -I{} mpsolve -p '{}' | tr -d '(),' > rp-d$D.gp
cat rp-d$D.gp | ./clog.py > ln_rp-d$D.gp
85 changes: 85 additions & 0 deletions wiki/src/randpoly.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* License: CC0
*
* To the extent possible under law, the person who associated CC0 with
* this project has waived all copyright and related or neighboring rights
* to this project.
*
* You should have received a copy of the CC0 legalcode along with this
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int rand_uniform_poly(double *coef, int n, double min_c, double max_c) {

int i;

for (i=0; i<n; i++) {
coef[i] = ((max_c - min_c)*((double)rand() / (RAND_MAX+1.0))) + min_c;
}

return 0;
}

int print_poly(double *coef, int n) {
int i;

for (i=0; i<n; i++) {

if (i==0) {
printf("%f", coef[i]);
continue;
}

if (coef[i] > 0.0) { printf("+"); }
printf("%f*x^%i", coef[i], i);
}
printf("\n");
}


int main(int argc, char **argv) {
int i, j, k, it;
int n_poly;

int n;
double min_c, max_c;

double *coef;

min_c = -1.0;
max_c = 1.0;

n_poly = 100;
n = 32;

if (argc>1) {
n = atoi(argv[1]);
if (argc>2) {
n_poly = atoi(argv[2]);

if (argc>3) {
min_c = atof(argv[3]);

if (argc>4) {
max_c = atof(argv[4]);
}
}
}
}

coef = (double *)malloc(sizeof(double)*n);
memset(coef, 0, sizeof(double)*n);

for (it=0; it<n_poly; it++) {

rand_uniform_poly(coef, n, min_c, max_c);

print_poly(coef, n);

}
}

0 comments on commit 2f65d6e

Please sign in to comment.