public void Trace_WithInvalidDimension_ThrowException() { // arrange var device = HostDevice.Instance; var input = NdArray <int> .Arange(device, 0, 27, 1); // action var trace = ReductionFunction <int> .Trace(input); }
public void SumAxis() { // arrange var device = HostDevice.Instance; var input = NdArray <double> .Arange(device, 1, 9, 1).Reshape(new[] { 2, 4 }); // action var sum = ReductionFunction <double> .SumAxis(1, input); // assert Assert.AreEqual(10.0, sum[0].Value); }
public void MinNdArray() { // arrange var device = HostDevice.Instance; var input = NdArray <double> .Arange(device, 1, 9, 1).Reshape(new[] { 2, 4 }); // action var min = ReductionFunction <double> .MinNdArray(input); // assert Assert.AreEqual(1.0, min[0].Value); }
public void ProductNdArray() { // arrange var device = HostDevice.Instance; var input = NdArray <double> .Arange(device, 1, 9, 1).Reshape(new[] { 2, 4 }); // action var product = ReductionFunction <double> .ProductNdArray(input); // assert Assert.AreEqual(40320.0, product[0].Value); }
public void Mean() { // arrange var device = HostDevice.Instance; var input = NdArray <double> .Arange(device, 1, 9, 1).Reshape(new[] { 2, 4 }); // action var sum = ReductionFunction <double> .Mean(input); // assert Assert.AreEqual(4.5, sum); }
public void MeanAxis() { // arrange var device = HostDevice.Instance; var input = NdArray <double> .Arange(device, 1, 9, 1).Reshape(new[] { 2, 4 }); // action var mean = ReductionFunction <double> .MeanAxis(1, input); // assert Assert.AreEqual(2.5, mean[0].Value); }
public void Trace() { // arrange var device = HostDevice.Instance; var input = NdArray <int> .Arange(device, 0, 27, 1).Reshape(new[] { 3, 3, 3 }); // action var trace = ReductionFunction <int> .Trace(input); // assert Assert.AreEqual(12, trace[0].Value); Assert.AreEqual(39, trace[1].Value); Assert.AreEqual(66, trace[2].Value); }
public void StdAxis_Ddof1() { // arrange var device = HostDevice.Instance; var input = NdArray <double> .Arange(device, 1, 9, 1).Reshape(new[] { 2, 4 }); // action var std = ReductionFunction <double> .StdAxis(1, input, 1.0); // assert const double Epsilon = 1e-8; Assert.IsTrue(Math.Abs(1.29099445 - std[0].Value) < Epsilon); }
/// <summary> /// /// </summary> /// <param name="aparameter">Nombre de la clase a instanciar, esta clase debe heredar de ClusterAlgorithm</param> /// <param name="aresult"></param> /// <returns></returns> public bool TryConvert(string aparameter, out object aresult) { ReductionFunction _temp = ReflectionTools.GetInstance <ReductionFunction>("ClusterEnsemble.ReductionFunctions." + aparameter); if (_temp != null) { aresult = _temp; return(true); } else { aresult = null; return(false); } }
public Structuring BuildStructuringWithReduction() { try { if (ReductionFunction == null) { throw new ArgumentNullException(); } List <Structuring> _tempStructurings = Structurings; Set _tempSet = Set; Set _newSet = null; Stopwatch _Stopwatch = new Stopwatch(); _Stopwatch.Start(); List <Structuring> _reduction = ReductionFunction.GetReduction(Set, Structurings, out _newSet); Set = _newSet; Structurings = _reduction; RealSet = _tempSet; RealStructurings = _tempStructurings; ReductionElementCount = _newSet.ElementsCount; Structuring _temp = this.BuildStructuring(); Structuring = ReductionFunction.TurnOffReduction(Set, _temp); _Stopwatch.Stop(); Time = _Stopwatch.Elapsed; Structurings = _tempStructurings; Set = _tempSet; RealStructurings = null; RealSet = null; return(Structuring); } catch (Exception) { throw; } }
private void RunFinish(Structuring aStructuring, ConsensusFunction aConsensusFunction) { try { ConsensusFunction _EnsembleAlg = aConsensusFunction; Structuring _structuring = aStructuring; if (_structuring != null) { TimeSpan ts = _EnsembleAlg.Time; string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); PartitionInfo _partInfo = new PartitionInfo() { AlgorithmName = this.tb_SelectEnsembleAlg.Text, ConsensusFunction = _EnsembleAlg, Partition = _structuring, AlgorithmType = AlgorithmType.Ensemble, Time = elapsedTime, ElementCount = aConsensusFunction.ReductionElementCount, SearchSpace = ReductionFunction.BellNumber(aConsensusFunction.ReductionElementCount), Index = -1 }; this.uctrl_ListClusterAlgVisualizerEnsemble.AddPartitionInfo(_partInfo); this.tb_output.Text = _EnsembleAlg.Output; if (NewStructuringEventHandler != null) { NewStructuringEventHandler(this, new NewStructuringEventArgs(_partInfo)); } } } catch (Exception _ex) { GeneralTools.Tools.WriteToLog(_ex); } }