forked from n64decomp/sm64
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
n64
committed
Aug 25, 2019
1 parent
89e8690
commit b333dd0
Showing
8 changed files
with
868 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
*.o | ||
*.s | ||
*.dump | ||
*.aiff | ||
*.aifc | ||
*.table | ||
/tabledesign_irix | ||
/tabledesign_native | ||
/tabledesign_orig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Makefile for building tabledesign for either IRIX or natively. | ||
# For an IRIX build, the env variable IRIX_ROOT should point to the root of an | ||
# IRIX filesystem, and QEMU_IRIX should point to the qemu-irix binary. | ||
|
||
IRIX_CC := $(QEMU_IRIX) -silent -L $(IRIX_ROOT) $(IRIX_ROOT)/usr/bin/cc | ||
IRIX_CFLAGS := -fullwarn -Wab,-r4300_mul -Xcpluscomm -mips1 -O2 | ||
|
||
NATIVE_CC := gcc | ||
NATIVE_CFLAGS := -Wall -Wno-uninitialized -O2 | ||
|
||
LDFLAGS := -lm -laudiofile | ||
|
||
default: native | ||
all: irix native | ||
|
||
irix: tabledesign_irix | ||
native: tabledesign_native | ||
|
||
clean: | ||
$(RM) *.o tabledesign_irix tabledesign_native | ||
|
||
%.o: %.c | ||
$(IRIX_CC) -c $(IRIX_CFLAGS) $< -o $@ | ||
|
||
tabledesign_irix: tabledesign.o codebook.o estimate.o print.o | ||
$(IRIX_CC) $^ -o $@ $(LDFLAGS) | ||
|
||
tabledesign_native: tabledesign.c codebook.c estimate.c print.c | ||
$(NATIVE_CC) $(NATIVE_CFLAGS) $^ -o $@ $(LDFLAGS) | ||
|
||
.PHONY: default all irix native clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#include <stdlib.h> | ||
#include "tabledesign.h" | ||
|
||
void split(double **table, double *delta, int order, int npredictors, double scale) | ||
{ | ||
int i, j; | ||
|
||
for (i = 0; i < npredictors; i++) | ||
{ | ||
for (j = 0; j <= order; j++) | ||
{ | ||
table[i + npredictors][j] = table[i][j] + delta[j] * scale; | ||
} | ||
} | ||
} | ||
|
||
void refine(double **table, int order, int npredictors, double **data, int dataSize, int refineIters, UNUSED double unused) | ||
{ | ||
int iter; // spD8 | ||
double **rsums; | ||
int *counts; // spD0 | ||
double *temp_s7; | ||
double dist; | ||
double dummy; // spC0 | ||
double bestValue; | ||
int bestIndex; | ||
int i, j; | ||
|
||
rsums = malloc(npredictors * sizeof(double*)); | ||
for (i = 0; i < npredictors; i++) | ||
{ | ||
rsums[i] = malloc((order + 1) * sizeof(double)); | ||
} | ||
|
||
counts = malloc(npredictors * sizeof(int)); | ||
temp_s7 = malloc((order + 1) * sizeof(double)); | ||
|
||
for (iter = 0; iter < refineIters; iter++) | ||
{ | ||
for (i = 0; i < npredictors; i++) | ||
{ | ||
counts[i] = 0; | ||
for (j = 0; j <= order; j++) | ||
{ | ||
rsums[i][j] = 0.0; | ||
} | ||
} | ||
|
||
for (i = 0; i < dataSize; i++) | ||
{ | ||
bestValue = 1e30; | ||
bestIndex = 0; | ||
|
||
for (j = 0; j < npredictors; j++) | ||
{ | ||
dist = model_dist(table[j], data[i], order); | ||
if (dist < bestValue) | ||
{ | ||
bestValue = dist; | ||
bestIndex = j; | ||
} | ||
} | ||
|
||
counts[bestIndex]++; | ||
rfroma(data[i], order, temp_s7); | ||
for (j = 0; j <= order; j++) | ||
{ | ||
rsums[bestIndex][j] += temp_s7[j]; | ||
} | ||
} | ||
|
||
for (i = 0; i < npredictors; i++) | ||
{ | ||
if (counts[i] > 0) | ||
{ | ||
for (j = 0; j <= order; j++) | ||
{ | ||
rsums[i][j] /= counts[i]; | ||
} | ||
} | ||
} | ||
|
||
for (i = 0; i < npredictors; i++) | ||
{ | ||
durbin(rsums[i], order, temp_s7, table[i], &dummy); | ||
|
||
for (j = 1; j <= order; j++) | ||
{ | ||
if (temp_s7[j] >= 1.0) temp_s7[j] = 0.9999999999; | ||
if (temp_s7[j] <= -1.0) temp_s7[j] = -0.9999999999; | ||
} | ||
|
||
afromk(temp_s7, table[i], order); | ||
} | ||
} | ||
|
||
free(counts); | ||
for (i = 0; i < npredictors; i++) | ||
{ | ||
free(rsums[i]); | ||
} | ||
free(rsums); | ||
free(temp_s7); | ||
} |
Oops, something went wrong.