private bool HasReplicates(IMatrixProvider src) { if (src == null) { return(false); } IntensityMatrix matrix = src.Provide; if (matrix == null) { return(false); } for (int i = 0; i < matrix.NumCols; ++i) { for (int j = 0; j < i; ++j) { var a = matrix.Columns[i].Observation; var b = matrix.Columns[j].Observation; if (a.IsReplicateOf(b)) { return(true); } } } return(false); }
public ChunkRenderer(IChunk chunk, Func <ITexture2DAtlas> textureAtlasProvider, IMatrixProvider <Matrix4, Vector4> viewMatrix, IMatrixProvider <Matrix4, Vector4> projectionMatrix) { _chunk = chunk; _textureAtlasProvider = textureAtlasProvider; _viewMatrix = viewMatrix; _projectionMatrix = projectionMatrix; }
public readonly ObsFilter Constraint; // (ONLY FOR TREND-BASED CORRECTIONS) Constraint on the input vector public ArgsCorrection(string id, IMatrixProvider source, object[] parameters, ECorrectionMode mode, ECorrectionMethod method, GroupInfo controlGroup, ObsFilter constraint) : base(id, source, parameters) { Mode = mode; Method = method; ControlGroup = controlGroup; Constraint = constraint; }
public GaussianBlur(IImageD_Provider imaged_provider, double ro) { this.blue_channel = new MatrixProviders.GaussianBlur(MatrixProviders.Filter.Blue(imaged_provider), ro); this.green_channel = new MatrixProviders.GaussianBlur(MatrixProviders.Filter.Green(imaged_provider), ro); this.red_channel = new MatrixProviders.GaussianBlur(MatrixProviders.Filter.Red(imaged_provider), ro); this.alpha_channel = new MatrixProviders.GaussianBlur(MatrixProviders.Filter.Alpha(imaged_provider), ro); this.ro = ro; }
public readonly Peak VectorBPeak; // Which peak the second input vector comes from (only used if [VectorBSource] is AltPeak) public ArgsStatistic(string id, IMatrixProvider source, ObsFilter atypes, EAlgoInputBSource bsrc, ObsFilter btypes, Peak compareTo, object[] parameters) : base(id, source, parameters) { this.VectorAConstraint = atypes; this.VectorBConstraint = btypes; this.VectorBSource = bsrc; this.VectorBPeak = compareTo; }
public HarrisDetectorResponse(IMatrixProvider provider) { var mp_ix = new DerivativeX(new GaussianBlurX(provider, 1)); var mp_iy = new DerivativeY(new GaussianBlurY(provider, 1)); var mp_sxx = new GaussianBlur(new Dot(mp_ix, mp_ix), 1.5); var mp_sxy = new GaussianBlur(new Dot(mp_ix, mp_iy), 1.5); var mp_syy = new GaussianBlur(new Dot(mp_iy, mp_iy), 1.5); this.provider = new Detector(mp_sxx, mp_sxy, mp_syy); }
/// <summary> /// Constructor. /// </summary> public ArgsClusterer(string id, IMatrixProvider source, PeakFilter sigFilter, ConfigurationMetric distance, ObsFilter atypes, bool splitGroups, EClustererStatistics suppressMetric, object[] parameters, string clusterNamePrefix) : base(id, source, parameters) { this.PeakFilter = sigFilter; this.Distance = distance; this.ObsFilter = atypes; this.SplitGroups = splitGroups; this.Statistics = suppressMetric; this.OverrideShortName = clusterNamePrefix; }
public JpegDecompressor(IDctDecompressor dctDecompressor, IBitmapBuilder bitmapBuilder, IChannelsPacker <YCbCrChannels, YCbCrPixel> iChannelsPacker, IPieceMatrixExtender <double> pieceMatrixExtender, int dctSize, IMatrixProvider <double> lumiaMatrixProvider, IMatrixProvider <double> colorMatrixProvider) { _dctDecompressor = dctDecompressor; _dctSize = dctSize; _lumiaMatrixProvider = lumiaMatrixProvider; _colorMatrixProvider = colorMatrixProvider; _pieceMatrixExtender = pieceMatrixExtender; _iChannelsPacker = iChannelsPacker; _bitmapBuilder = bitmapBuilder; }
void find_distance_range() { ProgressReporter prog = new ProgressReporter(this); double smallest = double.MaxValue; double largest = double.MinValue; Tuple <Peak, Peak> smallestT = null; Tuple <Peak, Peak> largestT = null; IMatrixProvider vmatrix = DataSet.ForMatrixProviders(this._core).ShowList(this, null); if (vmatrix == null) { return; } ConfigurationMetric metric = new ConfigurationMetric(); metric.Args = new ArgsMetric(Algo.ID_METRIC_EUCLIDEAN, vmatrix, null); DistanceMatrix dmatrix = DistanceMatrix.Create(this._core, vmatrix.Provide, metric, prog); for (int peakIndex1 = 0; peakIndex1 < this._core.Peaks.Count; peakIndex1++) { for (int peakIndex2 = 0; peakIndex2 < this._core.Peaks.Count; peakIndex2++) { if (peakIndex1 != peakIndex2) { double result = dmatrix.Values[peakIndex1, peakIndex2]; Peak peak1 = this._core.Peaks[peakIndex1]; Peak peak2 = this._core.Peaks[peakIndex2]; if (result > largest) { largest = result; largestT = new Tuple <Peak, Peak>(peak1, peak2); } if (result < smallest) { smallest = result; smallestT = new Tuple <Peak, Peak>(peak1, peak2); } } } } StringBuilder sb = new StringBuilder(); sb.AppendLine("| " + smallestT.Item1.DisplayName + " - " + smallestT.Item2.DisplayName + " | = " + smallest); sb.AppendLine("| " + largestT.Item1.DisplayName + " - " + largestT.Item2.DisplayName + " | = " + largest); FrmInputMultiLine.ShowFixed(this, "Find distance range", "Maximum and minimum differences", "Showing the closest and furthest peaks", sb.ToString()); }
public ImageViewer(IMatrixProvider provider) : this() { provider.MatrixChanged += (matrix) => { if (!this.Dispatcher.CheckAccess()) { Dispatcher.Invoke(() => img.Source = matrix.ToHeatImage(1).ToBitmapSource()); } else { img.Source = matrix.ToHeatImage(1).ToBitmapSource(); } }; }
public void Should_ComputeRating_ForStandardInput() { //arrange IMatrixProvider matrixProvider = A.Fake <IMatrixProvider>(); IValidatorService validatorService = A.Fake <IValidatorService>(); IColleyMatrixService colleyMatrixService = new ColleyMatrixService(matrixProvider, validatorService); //act IEnumerable <double> solvedVector = colleyMatrixService.Solve(); //assert A.CallTo(() => matrixProvider.LowerUpperFactorizeAndSolve(null)).WithAnyArguments().MustHaveHappened(); }
public JpegCompressor(IDctCompressor dctCompressor, IPixelsExtractor <RgbPixel> pixelsExtractor, IChannelsExtractor <YCbCrChannels, YCbCrPixel> channelExtractor, IMatrixThinner <double> matrixThinner, int thinIndex, int compressionLevel, int dctSize, IMatrixExtender matrixExtender, IMatrixProvider <double> lumiaMatrixProvider, IMatrixProvider <double> colorMatrixProvider) { _matrixThinner = matrixThinner; _thinIndex = thinIndex; _compressionLevel = compressionLevel; _dctSize = dctSize; _matrixExtender = matrixExtender; _lumiaMatrixProvider = lumiaMatrixProvider; _colorMatrixProvider = colorMatrixProvider; _channelExtractor = channelExtractor; _dctCompressor = dctCompressor; _pixelsExtractor = pixelsExtractor; }
public CloudRenderer(IEye eye, IMatrixProvider <Matrix4, Vector4> viewMatrix, IMatrixProvider <Matrix4, Vector4> projectionMatrix, IAssetProvider resource) { _eye = eye; _viewMatrix = viewMatrix; _projectionMatrix = projectionMatrix; using var stream = resource[AssetType.Texture, "minecraft:environment/clouds.png"].OpenRead(); var cloudData = new Image(stream).Data; for (var y = 0; y < 256; y++) { for (var x = 0; x < 256; x++) { var l = y << 10 | x << 2; var r = cloudData[l]; var g = cloudData[l | 0b01];
public void Should_ComputeColleyRating_ForStandardInput() { //arrange double wins = 0; double losses = 1; double expectedOutput = 0.5; IMatrixProvider matrixProvider = A.Fake <IMatrixProvider>(); IValidatorService validatorService = A.Fake <IValidatorService>(); IColleyMatrixService colleyMatrixService = new ColleyMatrixService(matrixProvider, validatorService); //act double actualOutput = colleyMatrixService.ComputeColleyRating(wins, losses); //assert actualOutput.Should().Be(expectedOutput); }
public void ShouldNot_ValidateTeam_ForGreaterThanDimensionInput() { //arrange int dimensions = 2; int teamId = 2; IMatrixProvider matrixProvider = A.Fake <IMatrixProvider>(); IValidatorService validatorService = new ValidatorService(matrixProvider); A.CallTo(() => matrixProvider.GetDimensions()).Returns(dimensions); //act Action action = () => validatorService.ValidateTeam(teamId); //assert action.Should().Throw <InvalidTeamIndexException>(); }
private ArgsTrend GetSelection() { TrendBase sel = (TrendBase)this._ecbMethod.SelectedItem; string title; object[] args; this._checker.Clear(); // Title / comments title = string.IsNullOrWhiteSpace(this._txtName.Text) ? null : this._txtName.Text; // Parameters if (sel != null) { if (sel.Parameters.HasCustomisableParams) { string error; args = sel.Parameters.TryStringToParams(this._core, this._txtParams.Text, out error); this._checker.Check(this._txtParams, args != null, error ?? "error"); } else { args = null; } } else { args = null; this._checker.Check(this._ecbMethod.ComboBox, false, "Select a method"); } IMatrixProvider src = this._ecbSource.SelectedItem; this._checker.Check(this._ecbSource.ComboBox, src != null, "Select a source"); if (this._checker.HasErrors) { return(null); } return(new ArgsTrend(sel.Id, src, args) { OverrideDisplayName = title, Comment = this._comments }); }
/// <summary> /// Instantiates a ColleyMatrixService object /// </summary> /// <param name="matrixProvider">An abstraction for the underlying sparse matrix</param> /// <param name="validatorService">A service for validating input and output</param> public ColleyMatrixService(IMatrixProvider matrixProvider, IValidatorService validatorService) { _matrixProvider = matrixProvider; _validatorService = validatorService; _dimensions = _matrixProvider.GetDimensions(); _teams = new List <Team>(); for (int teamId = 0; teamId < _dimensions; teamId++) { _teams.Add(new Team() { TeamId = teamId, Wins = 0, Losses = 0, //initialize all ratings to 1 ColleyRating = 1 }); } }
public void Should_SimluateGame_ForStandardInput() { //arrange int dimensions = 2; int winnerId = 0; int loserId = 1; IMatrixProvider matrixProvider = A.Fake <IMatrixProvider>(); IValidatorService validatorService = A.Fake <IValidatorService>(); A.CallTo(() => matrixProvider.GetDimensions()).Returns(dimensions); IColleyMatrixService colleyMatrixService = new ColleyMatrixService(matrixProvider, validatorService); //act colleyMatrixService.SimulateGame(winnerId, loserId); //assert A.CallTo(() => validatorService.ValidateTeam(winnerId)).MustHaveHappened(); A.CallTo(() => validatorService.ValidateTeam(loserId)).MustHaveHappened(); }
void view_variable_full() { IMatrixProvider im = DataSet.ForMatrixProviders(this._core).ShowList(this, null); if (im == null) { return; } Vector peak = this.PickVariable(im.Provide); if (peak != null) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < peak.Observations.Length; i++) { ObservationInfo obs = peak.Observations[i]; sb.AppendLine(obs.Time + obs.Group.DisplayShortName + obs.Rep + " = " + peak.Values[i]); } FrmInputMultiLine.ShowFixed(this, "View full variable", peak.ToString(), "Full variable information", sb.ToString()); } }
private FrmPca(Core core, FrmMain frmMain) { this.InitializeComponent(); UiControls.SetIcon(this); UiControls.ColourMenuButtons(this.toolStrip1); this._frmMain = frmMain; this._core = core; this._peakFilter = PeakFilter.Empty; this._obsFilter = ObsFilter.Empty; this._selectedCorrection = core.Options.SelectedMatrixProvider; this._colourBy._colourByPeak = ColumnManager.GetColumns <Peak>(this._core).First(z => z.Id == Peak.ID_COLUMN_CLUSTERCOMBINATION); this._colourBy._colourByObervation = ColumnManager.GetColumns <ObservationInfo>(this._core).First(z => z.Id == nameof(ObservationInfo.Group)); this._regressAgainst._colourByPeak = this._colourBy._colourByPeak; this._regressAgainst._colourByObervation = this._colourBy._colourByObervation; this._chart.AddControls(this.toolStripDropDownButton1); this._chart.Style.LegendDisplay = ELegendDisplay.Visible; this.UpdateScores(); }
public Dot(IMatrixProvider provider1, IMatrixProvider provider2) { this.provider1 = provider1; this.provider2 = provider2; }
public HeatImageD(IMatrixProvider provider, double exp = 1) { this.provider = provider; this.exp = exp; }
private ArgsCorrection GetSelection() { this._checker.Clear(); IMatrixProvider source = this._ecbSource.SelectedItem; this._checker.Check(this._ecbSource.ComboBox, source != null, "Select a source"); // Algo AlgoBase algo = this._ecbMethod.SelectedItem; // Params object[] parameters; if (algo != null) { string error; parameters = algo.Parameters.TryStringToParams(this._core, this._txtParameters.Text, out error); this._checker.Check(this._txtParameters, parameters != null, error ?? "error"); } else { parameters = null; this._checker.Check(this._ecbMethod.ComboBox, false, "Select a correction method"); } if (algo is TrendBase) { // Method ECorrectionMethod met; if (this._radSubtract.Checked) { met = ECorrectionMethod.Subtract; } else if (this._radDivide.Checked) { met = ECorrectionMethod.Divide; } else { this._checker.Check(this._radSubtract, false, "Select a method"); this._checker.Check(this._radDivide, false, "Select a method"); met = default(ECorrectionMethod); } // Mode ECorrectionMode mode; GroupInfo controlGroup; ObsFilter filter; if (this._radBatch.Checked) { mode = ECorrectionMode.Batch; controlGroup = null; this._checker.Check(this._ecbFilter.ComboBox, this._ecbFilter.HasSelection, "Select a filter"); filter = this._ecbFilter.SelectedItem; } else if (this._radType.Checked) { mode = ECorrectionMode.Control; controlGroup = this._ecbTypes.SelectedItem; filter = null; } else { this._checker.Check(this._radBatch, false, "Select a mode"); this._checker.Check(this._radType, false, "Select a mode"); controlGroup = default(GroupInfo); filter = default(ObsFilter); mode = default(ECorrectionMode); } if (this._checker.HasErrors) { return(null); } ArgsCorrection args = new ArgsCorrection(((TrendBase)algo).Id, source, parameters, mode, met, controlGroup, filter) { OverrideDisplayName = this._txtName.Text, Comment = this._comments }; return(args); } else if (algo is CorrectionBase) { if (this._checker.HasErrors) { return(null); } ArgsCorrection args = new ArgsCorrection(((CorrectionBase)algo).Id, source, parameters, ECorrectionMode.None, ECorrectionMethod.None, null, null) { OverrideDisplayName = this._txtName.Text, Comment = this._comments }; return(args); } else { return(null); } }
public Clamp(IMatrixProvider provider, double mn, double mx) { this.provider = provider; this.mn = mn; this.mx = mx; }
public AxisRenderer(IMatrixProvider <Matrix4, Vector4> viewMatrix, IMatrixProvider <Matrix4, Vector4> projectionMatrix) { _viewMatrix = viewMatrix; _projectionMatrix = projectionMatrix; }
public SubpixelRefinement(IPointsProvider points_provider, IMatrixProvider mat_provider) { this.points_provider = points_provider; this.mat_provider = mat_provider; }
public ArgsMetric(string id, IMatrixProvider source, object[] parameters) : base(id, source, parameters) { }
public ProviderAlias(Core core, EProviderAlias source, IMatrixProvider userTarget) { this._core = core; this.Source = source; this._userTarget = new WeakReference <IMatrixProvider>(userTarget); }
public DerivativeY(IMatrixProvider provider) { this.provider = provider; }
/// <summary> /// Constructor /// </summary> protected ArgsBase(string id, IMatrixProvider sourceProvider, object[] parameters) { _sourceProvider = new WeakReference <IMatrixProvider>(sourceProvider); Id = id; Parameters = parameters; }