Intereting Posts

Is there a mathematical property which could help “sum up” information from certain matrix areas?
How do you proof that the simply periodic continuous fraction is palindromic for the square root of positive primes?
Why is the expected number coin tosses to get $HTH$ is $10$?
$L^1(μ)$ is finite dimensional if it is reflexive
Show that $(\mathbb Z,+)$ and $(\mathbb Q_{>0},\cdot)$ are isomorphic groups
Mathematical statement with simple independence proof from $\mathsf{ZF}$
Space of Germs of Holomorphic Function
Is there an integral that proves $\pi > 333/106$?
How many ways can we place two types of balls on a circle?
Looking for an identity for characteristic polynomial of a matrix to the power of n
Simplifying radicals inside radicals: $\sqrt{24+8\sqrt{5}}$
Can sum of a rational number and its reciprocal be an integer?
How to prove that the set $\{\sin(x),\sin(2x),…,\sin(mx)\}$ is linearly independent?
Uniform continuity and boundedness
Proof of Nesbitt's Inequality: $\frac{a}{b+c}+\frac{b}{c+a}+\frac{c}{a+b}\ge \frac{3}{2}$?

I have a matrix

$$A=

\begin{pmatrix}

2 & -1 & 4 \\

-3 & 8 & -5\\

12 & -7 & 16

\end{pmatrix}

$$

and I would like to create the matrix

- What is the intuitive meaning of the adjugate matrix?
- Lipschitz continuity of inverse
- Under what circumstance will a covariance matrix be positive semi-definite rather than positive definite?
- Matrices - Conditions for $AB+BA=0$
- Prove that if the sum of each row of $A$ equals $s$, then $s$ is an eigenvalue of $A$.
- Proof of matrix norm property: submultiplicativity

$$B=

\begin{pmatrix}

6 & 5 & 6 \\

11 & 26 & 15\\

10 & 21 & 12

\end{pmatrix}

$$

where each entry of B is the sum of its surrounding cells in $A$. So the first entry of $B$ is $2-1-3+8=6$. The $3\times 3$ matrix and the summing “radius” are a simplification, the question aims at $m \times n$ matrices along with arbitrary rectangular areas to be measured.

Is there some mathematical property which could help avoid having to implement something along the lines of

$$b_{kl}=\sum_{l-a}^{l+b}\sum_{k-c}^{k+d}a_{kl} ~~~\text{given that the entries exist}$$

? Special case: would things be easier if the entries only consisted of a fixed amount of $0$ and $1$?

- Linear Algebra,regarding commutator
- Determinant of a large block matrix
- Linear Transformation and Matrices
- A unitary matrix taking a real matrix to another real matrix, is it an orthogonal matrix?
- $I_m - AB$ is invertible if and only if $I_n - BA$ is invertible.
- When is matrix multiplication commutative?
- Algebra-sum of entries in each column of a sqaure matrix = constant
- The determinant of block triangular matrix as product of determinants of diagonal blocks
- If $A$ is an invertible skew-symmetric matrix, then prove $A^{-1}$ is also skew symmetric
- Short matrix algebra question

Your example is essentially a convolution of $2$-dim array of data using a $3 \times 3$ kernel.

For really large array and arbitrary kernel, one can use discrete fourier transform to speed up the computation.

In the case where the kernel is not too big, rectangular and binary ( i.e weight $1$ if inside rectangle, $0$ otherwise), one can use the trick of sum table to compute the sum.

Given any array of data $a_{xy}$, define

$$\Delta(x_0,y_0;x_1,y_1) = \sum_{x = x_0}^{x_1} \sum_{y = y_0}^{y_1} a_{xy}

\quad\text{ and }\quad

\Delta_0(x,y) = \Delta(0,0;x,y)$$

These functions satisfy:

$$\begin{align}

\Delta(x_0,y_0;x_1,y_1) &= \Delta_0(x_1,y_1) – \Delta_0(x_0-1,y_1) – \Delta_0(x_1,y_0-1) + \Delta_0(x_0-1,y_0-1)\\

\Delta_0(x_0,y_0) &= \Delta_0(x_0,y_0-1) + \sum_{x=0}^{x_0} a_{xy_0}

\end{align}

$$

Let’s say you have an $N_1 \times N_2$ array of data and you want to convolute it with a $M_1 \times M_2$ rectangular binary kernel.

You can build the sum table $\Delta_0$ by scanning along the rows,

storing the most recent seen $M_2+1$ rows of $\Delta_0$ and compute

the $\Delta$ using row sums from current row and the previous $M_2+1$-th row. In this way, you can compute all the $\Delta$ sums in $O(N_1 \times N_2)$ steps using $O(N_1 \times M_2)$ working storage.

You should browse over the questions tagged with

convolution

on dsp.SE (Signal processing) to see whether

there are some library you can use.

- When are two norms equivalent on a Banach space?
- Development of a specific hardware architecture for a particular algorithm
- Finding points on ellipse
- What is the difference between the Frobenius norm and the 2-norm of a matrix?
- Notation for n-ary exponentiation
- Is there a simpler way to falsify this?
- Measure theory and topology books that have solution manuals
- Existence of group of order $p$ in group of order $pq$, $p>q$
- Use two solutions to a high order linear homogeneous differential equation with constant coefficients to say something about the order of the DE
- How many integers between have digit sum 20?
- Interesting and unexpected applications of $\pi$
- Is this proof good? Identifying extreme points of the unit ball in a function space
- Solving 4th-order PDE
- How find this sum $I_n=\sum_{k=0}^{n}\frac{H_{k+1}H_{n-k+1}}{k+2}$
- Characterize the integers $a,b$ satisfying: $ab-1|a^2+b^2$