Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ScalarDivision.cs
1using System;
2
4{
8 public static partial class ArithmeticsOperations
9 {
15 public static void ScalarDivision(this Matrix<float> M, float Scalar)
16 {
17 if (Scalar == 0)
18 throw new ArgumentException("Division by zero.", nameof(Scalar));
19
20 M.ScalarMultiplication(1.0f / Scalar);
21 }
22
28 public static void ScalarDivision(this Matrix<int> M, int Scalar)
29 {
30 if (Scalar == 0)
31 throw new ArgumentException("Division by zero.", nameof(Scalar));
32
33 int y, h = M.Height;
34 int x, w = M.Width;
35 int Index = M.Start;
36 int Skip = M.Skip;
37 int[] Data = M.Data;
38
39 for (y = 0; y < h; y++, Index += Skip)
40 {
41 for (x = 0; x < w; x++)
42 Data[Index++] /= Scalar;
43 }
44 }
45 }
46}
static void ScalarDivision(this Matrix< int > M, int Scalar)
Performs a scalar division on each element in the matrix.
static void ScalarDivision(this Matrix< float > M, float Scalar)
Performs a scalar division on each element in the matrix.
Implements a Matrix, basic component for computations in Image Processing and Computer Vision.
Definition: Matrix.cs:12
int Height
Height of matrix (number of rows)
Definition: Matrix.cs:136
T[] Data
Underlying data on which the matrix is defined.
Definition: Matrix.cs:114
int Width
Width of matrix (number of columns)
Definition: Matrix.cs:120
int Skip
Number of elements to skip from the right edge in the underlying data to the left edge of the new row...
Definition: Matrix.cs:233
int Start
Start offset of matrix in underlying data.
Definition: Matrix.cs:228