本文整理汇总了C#中alglib类的典型用法代码示例。如果您正苦于以下问题:C# alglib类的具体用法?C# alglib怎么用?C# alglib使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
alglib类属于命名空间,在下文中一共展示了alglib类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MultinomialLogitModel
public MultinomialLogitModel(alglib.logitmodel logitModel, string targetVariable, IEnumerable<string> allowedInputVariables, double[] classValues)
: base(targetVariable) {
this.name = ItemName;
this.description = ItemDescription;
this.logitModel = logitModel;
this.allowedInputVariables = allowedInputVariables.ToArray();
this.classValues = (double[])classValues.Clone();
}
示例2: Decode
public static List<double> Decode(alglib.complex[] freqSamples, bool needWindow = false)
{
double[] outSamples;
alglib.fftr1dinv(freqSamples, out outSamples);
return outSamples.ToList();
}
示例3: NeuralNetworkModel
public NeuralNetworkModel(alglib.multilayerperceptron multiLayerPerceptron, string targetVariable, IEnumerable<string> allowedInputVariables, double[] classValues = null)
: base(targetVariable) {
this.name = ItemName;
this.description = ItemDescription;
this.multiLayerPerceptron = multiLayerPerceptron;
this.allowedInputVariables = allowedInputVariables.ToArray();
if (classValues != null)
this.classValues = (double[])classValues.Clone();
}
示例4: create_RF_signal
public static void create_RF_signal(alglib.complex[] baseband_signal, double Fd, double duration_of_signal, double Fc, double A, out alglib.complex[] RF_signal, out double[] t)
{
int samples = (int)(duration_of_signal * Fd);
t = new double[samples];
for (int i = 0; i < t.Length; i++)
{
t[i] = i / Fd;
}
RF_signal = new alglib.complex[t.Length];
for (int i = 0; i < t.Length; i++)
{
RF_signal[i] = A * baseband_signal[i] * new alglib.complex(Math.Cos(Fc * 2 * Math.PI * t[i]), Math.Sin(Fc * 2 * Math.PI * t[i]));
}
}//создание радиосигнала, перенос на несущую
示例5: NeuralNetworkEnsembleModel
public NeuralNetworkEnsembleModel(alglib.mlpensemble mlpEnsemble, string targetVariable, IEnumerable<string> allowedInputVariables, double[] classValues = null)
: base() {
this.name = ItemName;
this.description = ItemDescription;
this.mlpEnsemble = mlpEnsemble;
this.targetVariable = targetVariable;
this.allowedInputVariables = allowedInputVariables.ToArray();
if (classValues != null)
this.classValues = (double[])classValues.Clone();
}
示例6: convert
/// <summary>
///
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static IList<Complex> convert(alglib.complex[] source)
{
int count = source.Length;
IList<Complex> result = new Complex[count];
for (int i = 0; i < count; i++)
{
result[i] = new Complex(source[i].x, source[i].y);
}
return result;
}
示例7: splineSmoothFit
public static void splineSmoothFit(double[] x, double[] y, out alglib.spline1dinterpolant result, double rho = 0.3, int num_bases_functions = 50)
{
alglib.spline1dinterpolant s;
alglib.spline1dfitreport rep;
int info;
alglib.spline1dfitpenalized(x, y, num_bases_functions, rho, out info, out s, out rep);
result = s;
}
示例8: generate_mixed_chirp_signal
}//добавление АБГШ
public static void generate_mixed_chirp_signal(int chirp_num, double duration_of_signal, double Fd, double[] Fmin, double[] Fmax, double[] init_phase, double[] A, out double[] t, out alglib.complex[] mixed_signal)//Амплитуды в децибелах
{
t = new double[(int)(duration_of_signal * Fd)];
mixed_signal = new alglib.complex[(int)(duration_of_signal * Fd)];
alglib.complex[] noise = create_AWGN(mixed_signal.Length);
for (int i = 0; i < chirp_num; i++)
{
alglib.complex[] signal = chirp(Fmin[i], Fmax[i], Fd, duration_of_signal);
double coeff = get_null_dB_mag(signal, noise, Fmin[i], Fmax[i], Fd);
double new_coeff = Math.Sqrt(coeff * coeff * Math.Pow(10, A[i] / 10.0));
for (int j = 0; j < signal.Length; j++)
{
mixed_signal[j] += new_coeff * signal[j];
}
/* double noiseE = 0;
foreach (alglib.complex n in noise)
{
noiseE += Math.Pow(alglib.math.abscomplex(n), 2);
}
noiseE = noiseE * (Fmax[i] - Fmin[i]) / Fd;
double signalE = 0;
for (int j = 0; j < signal.Length; j++)
{
signalE += Math.Pow(alglib.math.abscomplex(new_coeff * signal[j]), 2);
}
double SNR =10* Math.Log10(signalE / noiseE) ;*/
}
/* double E_sig = 0;
foreach (alglib.complex val in mixed_signal)
{
E_sig += Math.Pow(alglib.math.abscomplex(val),2);
}
double E_noise = 0;
foreach (alglib.complex val in noise)
{
E_noise += Math.Pow(alglib.math.abscomplex(val),2);
}
double SNR = 10 * Math.Log10(E_sig / E_noise);*/
for (int j = 0; j < mixed_signal.Length; j++)
{
mixed_signal[j] += noise[j];
t[j] = j / Fd;
}
}
示例9: get_null_dB_mag
public static double get_null_dB_mag(alglib.complex[] signal, alglib.complex[] noise, double Fmin, double Fmax, double Fd)//получения амплитуды сигнала соотвествующей SNR=0,
{
double signal_mag = 0;
//int i_start = (int)(Fmin * (signal.Length - 1) / Fd);
//int i_end = (int)Math.Ceiling(Fmax * (signal.Length - 1) / Fd);
for (int i = 0; i < signal.Length; i++)
{
signal_mag += Math.Pow(alglib.math.abscomplex(signal[i]), 2);
}
/*for (int i = i_start; i <= i_end; i++)
{
signal_mag += Math.Pow(alglib.math.abscomplex(signal[i]), 2);
}*/
double noise_mag = 0;
for (int i = 0; i < noise.Length; i++)
{
noise_mag += Math.Pow(alglib.math.abscomplex(noise[i]), 2);
}
noise_mag = noise_mag * (Fmax - Fmin) / Fd;
double coeff = noise_mag / signal_mag;
return Math.Sqrt(coeff);
}//добавление АБГШ
示例10: kdtreeserialize
/*************************************************************************
Serializer: serialization
-- ALGLIB --
Copyright 14.03.2011 by Bochkanov Sergey
*************************************************************************/
public static void kdtreeserialize(alglib.serializer s,
kdtree tree)
{
//
// Header
//
s.serialize_int(scodes.getkdtreeserializationcode());
s.serialize_int(kdtreefirstversion);
//
// Data
//
s.serialize_int(tree.n);
s.serialize_int(tree.nx);
s.serialize_int(tree.ny);
s.serialize_int(tree.normtype);
apserv.serializerealmatrix(s, tree.xy, -1, -1);
apserv.serializeintegerarray(s, tree.tags, -1);
apserv.serializerealarray(s, tree.boxmin, -1);
apserv.serializerealarray(s, tree.boxmax, -1);
apserv.serializeintegerarray(s, tree.nodes, -1);
apserv.serializerealarray(s, tree.splits, -1);
}
示例11: dfunserialize
/*************************************************************************
Serializer: unserialization
-- ALGLIB --
Copyright 14.03.2011 by Bochkanov Sergey
*************************************************************************/
public static void dfunserialize(alglib.serializer s,
decisionforest forest)
{
int i0 = 0;
int i1 = 0;
//
// check correctness of header
//
i0 = s.unserialize_int();
alglib.ap.assert(i0==scodes.getrdfserializationcode(), "DFUnserialize: stream header corrupted");
i1 = s.unserialize_int();
alglib.ap.assert(i1==dffirstversion, "DFUnserialize: stream header corrupted");
//
// Unserialize data
//
forest.nvars = s.unserialize_int();
forest.nclasses = s.unserialize_int();
forest.ntrees = s.unserialize_int();
forest.bufsize = s.unserialize_int();
apserv.unserializerealarray(s, ref forest.trees);
}
示例12: dfalloc
/*************************************************************************
Serializer: allocation
-- ALGLIB --
Copyright 14.03.2011 by Bochkanov Sergey
*************************************************************************/
public static void dfalloc(alglib.serializer s,
decisionforest forest)
{
s.alloc_entry();
s.alloc_entry();
s.alloc_entry();
s.alloc_entry();
s.alloc_entry();
s.alloc_entry();
apserv.allocrealarray(s, forest.trees, forest.bufsize);
}
示例13: mlpeserialize
/*************************************************************************
Serializer: serialization
-- ALGLIB --
Copyright 14.03.2011 by Bochkanov Sergey
*************************************************************************/
public static void mlpeserialize(alglib.serializer s,
mlpensemble ensemble)
{
s.serialize_int(scodes.getmlpeserializationcode());
s.serialize_int(mlpefirstversion);
s.serialize_int(ensemble.ensemblesize);
apserv.serializerealarray(s, ensemble.weights, -1);
apserv.serializerealarray(s, ensemble.columnmeans, -1);
apserv.serializerealarray(s, ensemble.columnsigmas, -1);
mlpbase.mlpserialize(s, ensemble.network);
}
示例14: mlpunserialize
/*************************************************************************
Serializer: unserialization
-- ALGLIB --
Copyright 14.03.2011 by Bochkanov Sergey
*************************************************************************/
public static void mlpunserialize(alglib.serializer s,
multilayerperceptron network)
{
int i0 = 0;
int i1 = 0;
int i = 0;
int j = 0;
int k = 0;
int fkind = 0;
double threshold = 0;
double v0 = 0;
double v1 = 0;
int nin = 0;
int nout = 0;
bool issoftmax = new bool();
int[] layersizes = new int[0];
//
// check correctness of header
//
i0 = s.unserialize_int();
alglib.ap.assert(i0==scodes.getmlpserializationcode(), "MLPUnserialize: stream header corrupted");
i1 = s.unserialize_int();
alglib.ap.assert(i1==mlpfirstversion, "MLPUnserialize: stream header corrupted");
//
// Create network
//
issoftmax = s.unserialize_bool();
apserv.unserializeintegerarray(s, ref layersizes);
alglib.ap.assert((alglib.ap.len(layersizes)==2 || alglib.ap.len(layersizes)==3) || alglib.ap.len(layersizes)==4, "MLPUnserialize: too many hidden layers!");
nin = layersizes[0];
nout = layersizes[alglib.ap.len(layersizes)-1];
if( alglib.ap.len(layersizes)==2 )
{
if( issoftmax )
{
mlpcreatec0(layersizes[0], layersizes[1], network);
}
else
{
mlpcreate0(layersizes[0], layersizes[1], network);
}
}
if( alglib.ap.len(layersizes)==3 )
{
if( issoftmax )
{
mlpcreatec1(layersizes[0], layersizes[1], layersizes[2], network);
}
else
{
mlpcreate1(layersizes[0], layersizes[1], layersizes[2], network);
}
}
if( alglib.ap.len(layersizes)==4 )
{
if( issoftmax )
{
mlpcreatec2(layersizes[0], layersizes[1], layersizes[2], layersizes[3], network);
}
else
{
mlpcreate2(layersizes[0], layersizes[1], layersizes[2], layersizes[3], network);
}
}
//
// Load neurons and weights
//
for(i=1; i<=alglib.ap.len(layersizes)-1; i++)
{
for(j=0; j<=layersizes[i]-1; j++)
{
fkind = s.unserialize_int();
threshold = s.unserialize_double();
mlpsetneuroninfo(network, i, j, fkind, threshold);
for(k=0; k<=layersizes[i-1]-1; k++)
{
v0 = s.unserialize_double();
mlpsetweight(network, i-1, k, i, j, v0);
}
}
}
//
// Load standartizator
//
for(j=0; j<=nin-1; j++)
{
v0 = s.unserialize_double();
v1 = s.unserialize_double();
mlpsetinputscaling(network, j, v0, v1);
//.........这里部分代码省略.........
示例15: mlpalloc
/*************************************************************************
Serializer: allocation
-- ALGLIB --
Copyright 14.03.2011 by Bochkanov Sergey
*************************************************************************/
public static void mlpalloc(alglib.serializer s,
multilayerperceptron network)
{
int i = 0;
int j = 0;
int k = 0;
int fkind = 0;
double threshold = 0;
double v0 = 0;
double v1 = 0;
int nin = 0;
int nout = 0;
nin = network.hllayersizes[0];
nout = network.hllayersizes[alglib.ap.len(network.hllayersizes)-1];
s.alloc_entry();
s.alloc_entry();
s.alloc_entry();
apserv.allocintegerarray(s, network.hllayersizes, -1);
for(i=1; i<=alglib.ap.len(network.hllayersizes)-1; i++)
{
for(j=0; j<=network.hllayersizes[i]-1; j++)
{
mlpgetneuroninfo(network, i, j, ref fkind, ref threshold);
s.alloc_entry();
s.alloc_entry();
for(k=0; k<=network.hllayersizes[i-1]-1; k++)
{
s.alloc_entry();
}
}
}
for(j=0; j<=nin-1; j++)
{
mlpgetinputscaling(network, j, ref v0, ref v1);
s.alloc_entry();
s.alloc_entry();
}
for(j=0; j<=nout-1; j++)
{
mlpgetoutputscaling(network, j, ref v0, ref v1);
s.alloc_entry();
s.alloc_entry();
}
}