#include "msvc.h"
#include "learn.h"

extern "C" __declspec(dllexport) int getVersionNumber(int &val)
{
	val = 501;
	return 0;
}
extern "C" __declspec(dllexport) int createNetwork(void *&aNN, int networkType, char *password)
{

	switch (networkType)
	{
		case NS_RECALL_NETWORK:
			aNN = (void *) new NSRecallNetwork;
			break;
		case NS_LEARNING_NETWORK:
			aNN = (void *) new NSLearningNetwork;
			break;
		case NS_NETWORK:
		{
			return 3;
		}
		default:
			return 1;
		}

		return ((NSRecallNetwork *)aNN)->createNetwork();
}

extern "C" __declspec(dllexport) int getInputOutputInfo(void *aNN, int &inputs, int &outputs)
{
     ((NSRecallNetwork*) aNN)->getInputs(inputs);
     ((NSRecallNetwork*) aNN)->getOutputs(outputs);
     return 0;
}

extern "C" __declspec(dllexport) int loadWeights(void *aNN, char *weightsPathName)
{
     return ((NSRecallNetwork *) aNN)->loadWeights(weightsPathName);
}

extern "C" __declspec(dllexport) int saveWeights(void *aNN, char *weightsPathName)
{
     return ((NSRecallNetwork *) aNN)->saveWeights(weightsPathName, NULL);
}

extern "C" __declspec(dllexport) int randomizeWeights(void *aNN)
{
     return ((NSRecallNetwork*) aNN)->randomizeWeights();
}

extern "C" __declspec(dllexport) int resetNetwork(void *aNN)
{
     return ((NSRecallNetwork*) aNN)->resetNetwork();
}

extern "C" __declspec(dllexport) int getResponse(void *aNN, int exemplars, double *inputData, double *outputData)
{
     return ((NSRecallNetwork*) aNN)->getResponse(exemplars, inputData, outputData);
}

extern "C" __declspec(dllexport) int getSensitivity(void *aNN, int exemplars, double *inputData, double *&sensitivityData, double dither)
{
     return ((NSRecallNetwork*) aNN)->getSensitivity(exemplars, inputData, sensitivityData, dither);
}

extern "C" __declspec(dllexport) int destroyNetwork(void *aNN)
{
     int returnValue = ((NSRecallNetwork*) aNN)->destroyNetwork();
     delete (NSRecallNetwork*) aNN;
     return returnValue;
}

extern "C" __declspec(dllexport) int train(void *aNN, int epochs, int exemplars, double *inputData, double *desiredData, int CVExemplars, double *CVInputData, double *CVDesiredData)
{
     return ((NSRecallNetwork*) aNN)->train(epochs, exemplars, inputData, desiredData, CVExemplars, CVInputData, CVDesiredData);
}

extern "C" __declspec(dllexport) int setBestCost(void *aNN, double bestCost)
{
     return ((NSRecallNetwork*) aNN)->setBestCost(bestCost);
}

extern "C" __declspec(dllexport) int getBestCost(void *aNN, double &bestCost)
{
     return ((NSRecallNetwork*) aNN)->getBestCost(bestCost);
}

extern "C" __declspec(dllexport) int setBestWeightsPathName(void *aNN, char *bestWeightsPathName)
{
     return ((NSRecallNetwork*) aNN)->setBestWeightsPathName(bestWeightsPathName);
}

extern "C" __declspec(dllexport) int getBestWeightsPathName(void *aNN, char *bestWeightsPathName, int bufferLength, int &pathNameLength)
{
     return ((NSRecallNetwork*) aNN)->getBestWeightsPathName(bestWeightsPathName, bufferLength, pathNameLength);
}

extern "C" __declspec(dllexport) int setSaveBestWeightsEnabled(void *aNN, bool saveBestWeightsEnabled)
{
     return ((NSRecallNetwork*) aNN)->setSaveBestWeightsEnabled(saveBestWeightsEnabled);
}

extern "C" __declspec(dllexport) int getSaveBestWeightsEnabled(void *aNN, bool &saveBestWeightsEnabled)
{
     return ((NSRecallNetwork*) aNN)->getSaveBestWeightsEnabled(saveBestWeightsEnabled);
}

extern "C" __declspec(dllexport) int setSaveBestWeightsForTraining(void *aNN, bool saveBestWeightsForTraining)
{
     return ((NSRecallNetwork*) aNN)->setSaveBestWeightsForTraining(saveBestWeightsForTraining);
}

extern "C" __declspec(dllexport) int getSaveBestWeightsForTraining(void *aNN, bool &saveBestWeightsForTraining)
{
     return ((NSRecallNetwork*) aNN)->getSaveBestWeightsForTraining(saveBestWeightsForTraining);
}

extern "C" __declspec(dllexport) int setCrossValidationEnabled(void *aNN, bool crossValidationEnabled)
{
     return ((NSRecallNetwork*) aNN)->setCrossValidationEnabled(crossValidationEnabled);
}

extern "C" __declspec(dllexport) int getCrossValidationEnabled(void *aNN, bool &crossValidationEnabled)
{
     return ((NSRecallNetwork*) aNN)->getCrossValidationEnabled(crossValidationEnabled);
}

extern "C" __declspec(dllexport) int getInput(void *aNN, double *inputData, double *desiredData, double deltaThreshhold, double *newInputData)
{
     return ((NSRecallNetwork*) aNN)->getInput(inputData, desiredData, deltaThreshhold, newInputData);
}

extern "C" __declspec(dllexport) int setAutoComputeInputNormCoeff(void *aNN, bool autoComputeInputNormCoeff)
{
     return ((NSRecallNetwork*) aNN)->setAutoComputeInputNormCoeff(autoComputeInputNormCoeff);
}

extern "C" __declspec(dllexport) int getAutoComputeInputNormCoeff(void *aNN, bool &autoComputeInputNormCoeff)
{
     return ((NSRecallNetwork*) aNN)->getAutoComputeInputNormCoeff(autoComputeInputNormCoeff);
}

extern "C" __declspec(dllexport) int setAutoComputeOutputNormCoeff(void *aNN, bool autoComputeOutputNormCoeff)
{
     return ((NSRecallNetwork*) aNN)->setAutoComputeOutputNormCoeff(autoComputeOutputNormCoeff);
}

extern "C" __declspec(dllexport) int getAutoComputeOutputNormCoeff(void *aNN, bool &autoComputeOutputNormCoeff)
{
     return ((NSRecallNetwork*) aNN)->getAutoComputeOutputNormCoeff(autoComputeOutputNormCoeff);
}

extern "C" __declspec(dllexport) int removeInputNormalization(void *aNN)
{
     return ((NSRecallNetwork*) aNN)->removeInputNormalization();
}

extern "C" __declspec(dllexport) int removeOutputNormalization(void *aNN)
{
     return ((NSRecallNetwork*) aNN)->removeOutputNormalization();
}

extern "C" __declspec(dllexport) int setInputNormMin(void *aNN, double inputNormMin)
{
     return ((NSRecallNetwork*) aNN)->setInputNormMin(inputNormMin);
}

extern "C" __declspec(dllexport) int getInputNormMin(void *aNN, double &inputNormMin)
{
     return ((NSRecallNetwork*) aNN)->getInputNormMin(inputNormMin);
}

extern "C" __declspec(dllexport) int setInputNormMax(void *aNN, double inputNormMax)
{
     return ((NSRecallNetwork*) aNN)->setInputNormMax(inputNormMax);
}

extern "C" __declspec(dllexport) int getInputNormMax(void *aNN, double &inputNormMax)
{
     return ((NSRecallNetwork*) aNN)->getInputNormMax(inputNormMax);
}

extern "C" __declspec(dllexport) int setOutputNormMin(void *aNN, double outputNormMin)
{
     return ((NSRecallNetwork*) aNN)->setOutputNormMin(outputNormMin);
}

extern "C" __declspec(dllexport) int getOutputNormMin(void *aNN, double &outputNormMin)
{
     return ((NSRecallNetwork*) aNN)->getOutputNormMin(outputNormMin);
}

extern "C" __declspec(dllexport) int setOutputNormMax(void *aNN, double outputNormMax)
{
     return ((NSRecallNetwork*) aNN)->setOutputNormMax(outputNormMax);
}

extern "C" __declspec(dllexport) int getOutputNormMax(void *aNN, double &outputNormMax)
{
     return ((NSRecallNetwork*) aNN)->getOutputNormMax(outputNormMax);
}

extern "C" __declspec(dllexport) int setNormalizeInputByChannel(void *aNN, bool normalizeInputByChannel)
{
     return ((NSRecallNetwork*) aNN)->setNormalizeInputByChannel(normalizeInputByChannel);
}

extern "C" __declspec(dllexport) int getNormalizeInputByChannel(void *aNN, bool &normalizeInputByChannel)
{
     return ((NSRecallNetwork*) aNN)->getNormalizeInputByChannel(normalizeInputByChannel);
}

extern "C" __declspec(dllexport) int setNormalizeOutputByChannel(void *aNN, bool normalizeOutputByChannel)
{
     return ((NSRecallNetwork*) aNN)->setNormalizeOutputByChannel(normalizeOutputByChannel);
}

extern "C" __declspec(dllexport) int getNormalizeOutputByChannel(void *aNN, bool &normalizeOutputByChannel)
{
     return ((NSRecallNetwork*) aNN)->getNormalizeOutputByChannel(normalizeOutputByChannel);
}

extern "C" __declspec(dllexport) int getCostData(void *aNN, double *costData)
{
     return ((NSRecallNetwork*) aNN)->getCostData(costData);
}

extern "C" __declspec(dllexport) int getCrossValidationCostData(void *aNN, double *CVCostData)
{
     return ((NSRecallNetwork*) aNN)->getCrossValidationCostData(CVCostData);
}

extern "C" __declspec(dllexport) int getNumberOfEpochsTrained(void *aNN, int &numberOfEpochsTrained)
{
     return ((NSRecallNetwork*) aNN)->getNumberOfEpochsTrained(numberOfEpochsTrained);
}

extern "C" __declspec(dllexport) int getEpochOfBestCost(void *aNN, int &epochOfBestCost)
{
	return ((NSRecallNetwork*) aNN)->getEpochOfBestCost(epochOfBestCost);
}
extern "C" __declspec(dllexport) int seedRandom(void *aNN, unsigned int seed)
{
	return ((NSRecallNetwork*) aNN)->seedRandom(seed);
}

extern "C" __declspec(dllexport) int setUpdateMethod(void *aNN, int updateMethod)
{
     return ((NSRecallNetwork*) aNN)->setUpdateMethod(updateMethod);
}

extern "C" __declspec(dllexport) int getUpdateMethod(void *aNN, int &updateMethod)
{
     return ((NSRecallNetwork*) aNN)->getUpdateMethod(updateMethod);
}

extern "C" __declspec(dllexport) int setCustomExemplarsPerUpdate(void *aNN, int customExemplarsPerUpdate)
{
     return ((NSRecallNetwork*) aNN)->setCustomExemplarsPerUpdate(customExemplarsPerUpdate);
}

extern "C" __declspec(dllexport) int getCustomExemplarsPerUpdate(void *aNN, int &customExemplarsPerUpdate)
{
     return ((NSRecallNetwork*) aNN)->getCustomExemplarsPerUpdate(customExemplarsPerUpdate);
}

extern "C" __declspec(dllexport) int getGradient(void *aNN, double *costDerivativeData, double *gradientData)
{
     return ((NSRecallNetwork*) aNN)->getGradient(costDerivativeData, gradientData);
}

extern "C" __declspec(dllexport) int setNumberOfInputs(void *aNN, int numberOfInputs)
{
     return ((NSRecallNetwork*) aNN)->setNumberOfInputs(numberOfInputs);
}

extern "C" __declspec(dllexport) int setNumberOfOutputs(void *aNN, int numberOfOutputs)
{
     return ((NSRecallNetwork*) aNN)->setNumberOfOutputs(numberOfOutputs);
}

extern "C" __declspec(dllexport) int getNumberOfHiddenLayers(void *aNN, int &numberOfHiddenLayers)
{
     return ((NSRecallNetwork*) aNN)->getNumberOfHiddenLayers(numberOfHiddenLayers);
}

extern "C" __declspec(dllexport) int setNumberOfHiddenLayerPEs(void *aNN, int layerNumber, int numberOfHiddenLayerPEs)
{
     return ((NSRecallNetwork*) aNN)->setNumberOfHiddenLayerPEs(layerNumber, numberOfHiddenLayerPEs);
}

extern "C" __declspec(dllexport) int getNumberOfHiddenLayerPEs(void *aNN, int layerNumber, int &numberOfHiddenLayerPEs)
{
     return ((NSRecallNetwork*) aNN)->getNumberOfHiddenLayerPEs(layerNumber, numberOfHiddenLayerPEs);
}

extern "C" __declspec(dllexport) int getNumberOfStepSizes(void *aNN, int &numberOfStepSizes)
{
     return ((NSRecallNetwork*) aNN)->getNumberOfStepSizes(numberOfStepSizes);
}

extern "C" __declspec(dllexport) int setStepSize(void *aNN, int stepSizeNumber, double stepSize)
{
     return ((NSRecallNetwork*) aNN)->setStepSize(stepSizeNumber, stepSize);
}

extern "C" __declspec(dllexport) int getStepSize(void *aNN, int stepSizeNumber, double &stepSize)
{
     return ((NSRecallNetwork*) aNN)->getStepSize(stepSizeNumber, stepSize);
}

extern "C" __declspec(dllexport) int bumpStepSizes(void *aNN, double percent)
{
     return ((NSRecallNetwork*) aNN)->bumpStepSizes(percent);
}

extern "C" __declspec(dllexport) int getNumberOfMomentums(void *aNN, int &numberOfMomentums)
{
     return ((NSRecallNetwork*) aNN)->getNumberOfMomentums(numberOfMomentums);
}

extern "C" __declspec(dllexport) int setMomentum(void *aNN, int momentumNumber, double momentum)
{
     return ((NSRecallNetwork*) aNN)->setMomentum(momentumNumber, momentum);
}

extern "C" __declspec(dllexport) int getMomentum(void *aNN, int momentumNumber, double &momentum)
{
     return ((NSRecallNetwork*) aNN)->getMomentum(momentumNumber, momentum);
}

extern "C" __declspec(dllexport) int setSamplesPerExemplar(void *aNN, int samplesPerExemplar)
{
     return ((NSRecallNetwork*) aNN)->setSamplesPerExemplar(samplesPerExemplar);
}

extern "C" __declspec(dllexport) int getSamplesPerExemplar(void *aNN, int &samplesPerExemplar)
{
     return ((NSRecallNetwork*) aNN)->getSamplesPerExemplar(samplesPerExemplar);
}

extern "C" __declspec(dllexport) int setSamplesPerExemplarBackprop(void *aNN, int samplesPerExemplarBackprop)
{
     return ((NSRecallNetwork*) aNN)->setSamplesPerExemplarBackprop(samplesPerExemplarBackprop);
}

extern "C" __declspec(dllexport) int getSamplesPerExemplarBackprop(void *aNN, int &samplesPerExemplarBackprop)
{
     return ((NSRecallNetwork*) aNN)->getSamplesPerExemplarBackprop(samplesPerExemplarBackprop);
}

extern "C" __declspec(dllexport) int isDynamicNetwork(void *aNN, bool &dynamicNetwork)
{
     return ((NSRecallNetwork*) aNN)->isDynamicNetwork(dynamicNetwork);
}

extern "C" __declspec(dllexport) int getNumberOfTDNNAxons(void *aNN, int &numberOfTDNNAxons)
{
     return ((NSRecallNetwork*) aNN)->getNumberOfTDNNAxons(numberOfTDNNAxons);
}

extern "C" __declspec(dllexport) int setNumberOfTDNNAxonTaps(void *aNN, int axonNumber, int numberOfTDNNAxonTaps)
{
     return ((NSRecallNetwork*) aNN)->setNumberOfTDNNAxonTaps(axonNumber, numberOfTDNNAxonTaps);
}

extern "C" __declspec(dllexport) int getNumberOfTDNNAxonTaps(void *aNN, int axonNumber, int &numberOfTDNNAxonTaps)
{
     return ((NSRecallNetwork*) aNN)->getNumberOfTDNNAxonTaps(axonNumber, numberOfTDNNAxonTaps);
}

extern "C" __declspec(dllexport) int setOnEpochEndedFunctionPointer(void *aNN, void *onEpochEndedFunctionPointer)
{
     return ((NSRecallNetwork*) aNN)->setOnEpochEndedFunctionPointer(onEpochEndedFunctionPointer);
}

extern "C" __declspec(dllexport) int getCurrentCost(void *aNN, double &currentCost)
{
     return ((NSRecallNetwork*) aNN)->getCurrentCost(currentCost);
}

extern "C" __declspec(dllexport) int getCurrentCrossValidationCost(void *aNN, double &currentCVCost)
{
     return ((NSRecallNetwork*) aNN)->getCurrentCrossValidationCost(currentCVCost);
}

extern "C" __declspec(dllexport) int setInputDataMask(void *aNN, int *inputDataMask)
{
		return ((NSRecallNetwork*) aNN)->setInputDataMask(inputDataMask);
}

extern "C" __declspec(dllexport) int getInputDataMask(void *aNN, int *inputDataMask)
{
		return ((NSRecallNetwork*) aNN)->getInputDataMask(inputDataMask);
}

extern "C" __declspec(dllexport) int removeInputDataMask(void *aNN)
{
		return ((NSRecallNetwork*) aNN)->removeInputDataMask(true);
}

extern "C" __declspec(dllexport) int setUseRecencyOfObservationScaling(void *aNN, bool useRecencyOfObservationScaling)
{
	return ((NSRecallNetwork*) aNN)->setUseRecencyOfObservationScaling(useRecencyOfObservationScaling);
}

extern "C" __declspec(dllexport) int setUseDirectionOfChangeScaling(void *aNN, bool useDirectionOfChangeScaling)
{
	return ((NSRecallNetwork*) aNN)->setUseDirectionOfChangeScaling(useDirectionOfChangeScaling);
}

extern "C" __declspec(dllexport) int setUseMagnitudeOfChangeScaling(void *aNN, bool useMagnitudeOfChangeScaling)
{
	return ((NSRecallNetwork*) aNN)->setUseMagnitudeOfChangeScaling(useMagnitudeOfChangeScaling);
}

extern "C" __declspec(dllexport) int setSmallChangeScale(void *aNN, double smallChangeScale)
{
	return ((NSRecallNetwork*) aNN)->setSmallChangeScale(smallChangeScale);
}

extern "C" __declspec(dllexport) int setLargeChangeScale(void *aNN, double largeChangeScale)
{
	return ((NSRecallNetwork*) aNN)->setLargeChangeScale(largeChangeScale);
}

extern "C" __declspec(dllexport) int setRightDirectionScale(void *aNN, double rightDirectionScale)
{
	return ((NSRecallNetwork*) aNN)->setRightDirectionScale(rightDirectionScale);
}

extern "C" __declspec(dllexport) int setWrongDirectionScale(void *aNN, double wrongDirectionScale)
{
	return ((NSRecallNetwork*) aNN)->setWrongDirectionScale(wrongDirectionScale);
}

extern "C" __declspec(dllexport) int setSmallChangeRightDirectionScale(void *aNN, double smallChangeRightDirectionScale)
{
	return ((NSRecallNetwork*) aNN)->setSmallChangeRightDirectionScale(smallChangeRightDirectionScale);
}

extern "C" __declspec(dllexport) int setLargeChangeRightDirectionScale(void *aNN, double largeChangeRightDirectionScale)
{
	return ((NSRecallNetwork*) aNN)->setLargeChangeRightDirectionScale(largeChangeRightDirectionScale);
}

extern "C" __declspec(dllexport) int setSmallChangeWrongDirectionScale(void *aNN, double smallChangeWrongDirectionScale)
{
	return ((NSRecallNetwork*) aNN)->setSmallChangeWrongDirectionScale(smallChangeWrongDirectionScale);
}

extern "C" __declspec(dllexport) int setLargeChangeWrongDirectionScale(void *aNN, double largeChangeWrongDirectionScale)
{
	return ((NSRecallNetwork*) aNN)->setLargeChangeWrongDirectionScale(largeChangeWrongDirectionScale);
}

extern "C" __declspec(dllexport) int setDiscountRate(void *aNN, double discountRate)
{
	return ((NSRecallNetwork*) aNN)->setDiscountRate(discountRate);
}

extern "C" __declspec(dllexport) int setDataPreDifferenced(void *aNN, bool dataPreDifferenced)
{
	return ((NSRecallNetwork*) aNN)->setDataPreDifferenced(dataPreDifferenced);
}

extern "C" __declspec(dllexport) int setGradientDescentMethod(void *aNN, int newVal)
{
	return ((NSRecallNetwork*) aNN)->setGradientDescentMethod(newVal);
}

extern "C" __declspec(dllexport) int getGradientDescentMethod(void *aNN, int &val)
{
	return ((NSRecallNetwork*) aNN)->getGradientDescentMethod(val);
}

extern "C" __declspec(dllexport) int setHiddenLayerTransferFunction(void *aNN, int layerNumber, int newVal)
{
	return ((NSRecallNetwork*) aNN)->setHiddenLayerTransferFunction(layerNumber, newVal);
}

extern "C" __declspec(dllexport) int getHiddenLayerTransferFunction(void *aNN, int layerNumber, int &val)
{
	return ((NSRecallNetwork*) aNN)->getHiddenLayerTransferFunction(layerNumber, val);
}

extern "C" __declspec(dllexport) int setOutputLayerTransferFunction(void *aNN, int newVal)
{
	return ((NSRecallNetwork*) aNN)->setOutputLayerTransferFunction(newVal);
}

extern "C" __declspec(dllexport) int getOutputLayerTransferFunction(void *aNN, int &val)
{
	return ((NSRecallNetwork*) aNN)->getOutputLayerTransferFunction(val);
}

extern "C" __declspec(dllexport) int setHiddenLayerBeta(void *aNN, int layerNumber, double newVal)
{
	return ((NSRecallNetwork*) aNN)->setHiddenLayerBeta(layerNumber, newVal);
}

extern "C" __declspec(dllexport) int getHiddenLayerBeta(void *aNN, int layerNumber, double &val)
{
	return ((NSRecallNetwork*) aNN)->getHiddenLayerBeta(layerNumber, val);
}

extern "C" __declspec(dllexport) int setOutputLayerBeta(void *aNN, double newVal)
{
	return ((NSRecallNetwork*) aNN)->setOutputLayerBeta(newVal);
}

extern "C" __declspec(dllexport) int getOutputLayerBeta(void *aNN, double &val)
{
	return ((NSRecallNetwork*) aNN)->getOutputLayerBeta(val);
}

extern "C" __declspec(dllexport) int setHiddenLayerBiasVariance(void *aNN, int layerNumber, double newVal)
{
	return ((NSRecallNetwork*) aNN)->setHiddenLayerBiasVariance(layerNumber, newVal);
}

extern "C" __declspec(dllexport) int getHiddenLayerBiasVariance(void *aNN, int layerNumber, double &val)
{
	return ((NSRecallNetwork*) aNN)->getHiddenLayerBiasVariance(layerNumber, val);
}

extern "C" __declspec(dllexport) int setOutputLayerBiasVariance(void *aNN, double newVal)
{
	return ((NSRecallNetwork*) aNN)->setOutputLayerBiasVariance(newVal);
}

extern "C" __declspec(dllexport) int getOutputLayerBiasVariance(void *aNN, double &val)
{
	return ((NSRecallNetwork*) aNN)->getOutputLayerBiasVariance(val);
}

extern "C" __declspec(dllexport) int getMAPE(void *aNN, int exemplars, double *desiredData, double *outputData, int windowLength, double &MAPE)
{
	return ((NSRecallNetwork*) aNN)->getMAPE(exemplars, desiredData, outputData, windowLength, MAPE);
}

