Esempio n. 1
0
x = np.random.standard_normal((NVALS, ))
y = np.random.standard_normal((NVALS, ))
y_r = y * (1 - x)

s = ""

s += """
#define NVALS %d

""" % (NVALS, )

s += """
static float y_result[] = {
"""

s = complete_array(y_r, s)

s += """
static float y[] = {
"""

s = complete_array(y, s)

s += """
static float x[] = {
"""

s = complete_array(x, s)

outfile = os.environ['OUTFILE']
with open(outfile, "w") as f:
# Generate what the one-pole filter should output

import numpy as np
import os
from gen_common import complete_array

a = 0.99

NVALS = 1007

y = np.power(a, np.arange(NVALS))

s = ""

s += """
#define LEN_YN_TRUE %d

""" % (NVALS, )

s += """
static float yn_true[] = {
"""

s = complete_array(y, s)

outfile = os.environ['OUTFILE']
with open(outfile, "w") as f:
    f.write(s)
y1 = (x + 1) % M
y2 = (x + 2) % M

s = ""

s += """
#include <stdint.h>
#define NVALS %d
#define M %d
""" % (NVALS, M)

s += """
static uint32_t x[] = {
"""

s = complete_array(x, s, "%d,\n")

s += """
static uint32_t y0[] = {
"""
s = complete_array(y0, s, "%d,\n")

s += """
static uint32_t y1[] = {
"""
s = complete_array(y1, s, "%d,\n")

s += """
static uint32_t y2[] = {
"""
s = complete_array(y2, s, "%d,\n")
Esempio n. 4
0
# Make some data to test the functions
import numpy as np
import os
from gen_common import complete_array

outfile = os.environ['OUTFILE']

N_VALS = 1000
x1 = np.random.standard_normal((N_VALS, ))
x2 = np.random.standard_normal((N_VALS, ))
y1 = x1 + x2

s = """static float x1_test_data[] = {
"""
s = complete_array(x1, s)

s += """static float x2_test_data[] = {
"""
s = complete_array(x2, s)

s += """static float y1_test_data[] = {
"""
s = complete_array(y1, s)

with open(outfile, "w") as f:
    f.write(s)