Linear Algebra – How can I get all 4×4 submatrices of an nxn matrix?

You can use Subsets:

mat = Array(Subscript(a, ##)&, {6, 6});

TeXForm @ MatrixForm @ mat

$ left (
begin {array} {cccccc}
a_ {1,1} & a_ {1,2} & a_ {1,3} & a_ {1,4} & a_ {1,5} & a_ {1,6} \
a_ {2,1} & a_ {2,2} & a_ {2,3} & a_ {2,4} & a_ {2,5} & a_ {2,6} \
a_ {3.1} & a_ {3.2} & a_ {3.3} & a_ {3.4} & a_ {3.5} & a_ {3.6} \
a_ {4.1} & a_ {4.2} & a_ {4.3} & a_ {4.4} & a_ {4.5} & a_ {4.6} \
a_ {5,1} & a_ {5,2} & a_ {5,3} & a_ {5,4} & a_ {5,5} & a_ {5,6} \
a_ {6,1} & a_ {6,2} & a_ {6,3} & a_ {6,4} & a_ {6,5} & a_ {6,6} \
end {array}
right) $

fourbyfours =  mat((#, #)) & /@ Subsets(Range(6), {4});

TeXForm(Grid @ Partition(MatrixForm /@ fourbyfours, 3))

$ tiny begin {array} {ccc}
Left(
begin {array} {cccc}
a_ {1,1} & a_ {1,2} & a_ {1,3} & a_ {1,4} \
a_ {2,1} & a_ {2,2} & a_ {2,3} & a_ {2,4} \
a_ {3.1} & a_ {3.2} & a_ {3.3} & a_ {3.4} \
a_ {4.1} & a_ {4.2} & a_ {4.3} & a_ {4.4} \
end {array}
right left(
begin {array} {cccc}
a_ {1,1} & a_ {1,2} & a_ {1,3} & a_ {1,5} \
a_ {2,1} & a_ {2,2} & a_ {2,3} & a_ {2,5} \
a_ {3.1} & a_ {3.2} & a_ {3.3} & a_ {3.5} \
a_ {5,1} & a_ {5,2} & a_ {5,3} & a_ {5,5} \
end {array}
right left(
begin {array} {cccc}
a_ {1,1} & a_ {1,2} & a_ {1,3} & a_ {1,6} \
a_ {2,1} & a_ {2,2} & a_ {2,3} & a_ {2,6} \
a_ {3.1} & a_ {3.2} & a_ {3.3} & a_ {3.6} \
a_ {6,1} & a_ {6,2} & a_ {6,3} & a_ {6,6} \
end {array}
right) \
Left(
begin {array} {cccc}
a_ {1,1} & a_ {1,2} & a_ {1,4} & a_ {1,5} \
a_ {2,1} & a_ {2,2} & a_ {2,4} & a_ {2,5} \
a_ {4.1} & a_ {4.2} & a_ {4.4} & a_ {4.5} \
a_ {5,1} & a_ {5,2} & a_ {5,4} & a_ {5,5} \
end {array}
right left(
begin {array} {cccc}
a_ {1,1} & a_ {1,2} & a_ {1,4} & a_ {1,6} \
a_ {2,1} & a_ {2,2} & a_ {2,4} & a_ {2,6} \
a_ {4.1} & a_ {4.2} & a_ {4.4} & a_ {4.6} \
a_ {6,1} & a_ {6,2} & a_ {6,4} & a_ {6,6} \
end {array}
right left(
begin {array} {cccc}
a_ {1,1} & a_ {1,2} & a_ {1,5} & a_ {1,6} \
a_ {2.1} & a_ {2.2} & a_ {2.5} & a_ {2.6} \
a_ {5,1} & a_ {5,2} & a_ {5,5} & a_ {5,6} \
a_ {6,1} & a_ {6,2} & a_ {6,5} & a_ {6,6} \
end {array}
right) \
Left(
begin {array} {cccc}
a_ {1,1} & a_ {1,3} & a_ {1,4} & a_ {1,5} \
a_ {3.1} & a_ {3.3} & a_ {3.4} & a_ {3.5} \
a_ {4,1} & a_ {4,3} & a_ {4,4} & a_ {4,5} \
a_ {5,1} & a_ {5,3} & a_ {5,4} & a_ {5,5} \
end {array}
right left(
begin {array} {cccc}
a_ {1,1} & a_ {1,3} & a_ {1,4} & a_ {1,6} \
a_ {3,1} & a_ {3,3} & a_ {3,4} & a_ {3,6} \
a_ {4,1} & a_ {4,3} & a_ {4,4} & a_ {4,6} \
a_ {6,1} & a_ {6,3} & a_ {6,4} & a_ {6,6} \
end {array}
right left(
begin {array} {cccc}
a_ {1,1} & a_ {1,3} & a_ {1,5} & a_ {1,6} \
a_ {3.1} & a_ {3.3} & a_ {3.5} & a_ {3.6} \
a_ {5,1} & a_ {5,3} & a_ {5,5} & a_ {5,6} \
a_ {6,1} & a_ {6,3} & a_ {6,5} & a_ {6,6} \
end {array}
right) \
Left(
begin {array} {cccc}
a_ {1,1} & a_ {1,4} & a_ {1,5} & a_ {1,6} \
a_ {4,1} & a_ {4,4} & a_ {4,5} & a_ {4,6} \
a_ {5,1} & a_ {5,4} & a_ {5,5} & a_ {5,6} \
a_ {6,1} & a_ {6,4} & a_ {6,5} & a_ {6,6} \
end {array}
right left(
begin {array} {cccc}
a_ {2,2} & a_ {2,3} & a_ {2,4} & a_ {2,5} \
a_ {3,2} & a_ {3,3} & a_ {3,4} & a_ {3,5} \
a_ {4,2} & a_ {4,3} & a_ {4,4} & a_ {4,5} \
a_ {5,2} & a_ {5,3} & a_ {5,4} & a_ {5,5} \
end {array}
right left(
begin {array} {cccc}
a_ {2,2} & a_ {2,3} & a_ {2,4} & a_ {2,6} \
a_ {3,2} & a_ {3,3} & a_ {3,4} & a_ {3,6} \
a_ {4,2} & a_ {4,3} & a_ {4,4} & a_ {4,6} \
a_ {6,2} & a_ {6,3} & a_ {6,4} & a_ {6,6} \
end {array}
right) \
Left(
begin {array} {cccc}
a_ {2,2} & a_ {2,3} & a_ {2,5} & a_ {2,6} \
a_ {3,2} & a_ {3,3} & a_ {3,5} & a_ {3,6} \
a_ {5,2} & a_ {5,3} & a_ {5,5} & a_ {5,6} \
a_ {6,2} & a_ {6,3} & a_ {6,5} & a_ {6,6} \
end {array}
right left(
begin {array} {cccc}
a_ {2,2} & a_ {2,4} & a_ {2,5} & a_ {2,6} \
a_ {4,2} & a_ {4,4} & a_ {4,5} & a_ {4,6} \
a_ {5,2} & a_ {5,4} & a_ {5,5} & a_ {5,6} \
a_ {6,2} & a_ {6,4} & a_ {6,5} & a_ {6,6} \
end {array}
right left(
begin {array} {cccc}
a_ {3,3} & a_ {3,4} & a_ {3,5} & a_ {3,6} \
a_ {4,3} & a_ {4,4} & a_ {4,5} & a_ {4,6} \
a_ {5,3} & a_ {5,4} & a_ {5,5} & a_ {5,6} \
a_ {6,3} & a_ {6,4} & a_ {6,5} & a_ {6,6} \
end {array}
right) \
end {array} $

Alternatively, you can use Minors:

pminors = Diagonal @ Minors(mat, 4, Identity);
pminors == fourbyfours

True

If you want submatrices with successive indexes:

fourbyfoursconsec = Join @@ Partition(mat, {4, 4}, {1, 1});
Length@fourbyfoursconsec

9

TeXForm(Grid(Partition(MatrixForm /@ fourbyfoursconsec, 3)))

$ tiny begin {array} {ccc}
Left(
begin {array} {cccc}
a_ {1,1} & a_ {1,2} & a_ {1,3} & a_ {1,4} \
a_ {2,1} & a_ {2,2} & a_ {2,3} & a_ {2,4} \
a_ {3.1} & a_ {3.2} & a_ {3.3} & a_ {3.4} \
a_ {4.1} & a_ {4.2} & a_ {4.3} & a_ {4.4} \
end {array}
right left(
begin {array} {cccc}
a_ {1,2} & a_ {1,3} & a_ {1,4} & a_ {1,5} \
a_ {2,2} & a_ {2,3} & a_ {2,4} & a_ {2,5} \
a_ {3,2} & a_ {3,3} & a_ {3,4} & a_ {3,5} \
a_ {4,2} & a_ {4,3} & a_ {4,4} & a_ {4,5} \
end {array}
right left(
begin {array} {cccc}
a_ {1.3} & a_ {1.4} & a_ {1.5} & a_ {1.6} \
a_ {2,3} & a_ {2,4} & a_ {2,5} & a_ {2,6} \
a_ {3,3} & a_ {3,4} & a_ {3,5} & a_ {3,6} \
a_ {4,3} & a_ {4,4} & a_ {4,5} & a_ {4,6} \
end {array}
right) \
Left(
begin {array} {cccc}
a_ {2,1} & a_ {2,2} & a_ {2,3} & a_ {2,4} \
a_ {3.1} & a_ {3.2} & a_ {3.3} & a_ {3.4} \
a_ {4.1} & a_ {4.2} & a_ {4.3} & a_ {4.4} \
a_ {5,1} & a_ {5,2} & a_ {5,3} & a_ {5,4} \
end {array}
right left(
begin {array} {cccc}
a_ {2,2} & a_ {2,3} & a_ {2,4} & a_ {2,5} \
a_ {3,2} & a_ {3,3} & a_ {3,4} & a_ {3,5} \
a_ {4,2} & a_ {4,3} & a_ {4,4} & a_ {4,5} \
a_ {5,2} & a_ {5,3} & a_ {5,4} & a_ {5,5} \
end {array}
right left(
begin {array} {cccc}
a_ {2,3} & a_ {2,4} & a_ {2,5} & a_ {2,6} \
a_ {3,3} & a_ {3,4} & a_ {3,5} & a_ {3,6} \
a_ {4,3} & a_ {4,4} & a_ {4,5} & a_ {4,6} \
a_ {5,3} & a_ {5,4} & a_ {5,5} & a_ {5,6} \
end {array}
right) \
Left(
begin {array} {cccc}
a_ {3.1} & a_ {3.2} & a_ {3.3} & a_ {3.4} \
a_ {4.1} & a_ {4.2} & a_ {4.3} & a_ {4.4} \
a_ {5,1} & a_ {5,2} & a_ {5,3} & a_ {5,4} \
a_ {6,1} & a_ {6,2} & a_ {6,3} & a_ {6,4} \
end {array}
right left(
begin {array} {cccc}
a_ {3,2} & a_ {3,3} & a_ {3,4} & a_ {3,5} \
a_ {4,2} & a_ {4,3} & a_ {4,4} & a_ {4,5} \
a_ {5,2} & a_ {5,3} & a_ {5,4} & a_ {5,5} \
a_ {6,2} & a_ {6,3} & a_ {6,4} & a_ {6,5} \
end {array}
right left(
begin {array} {cccc}
a_ {3,3} & a_ {3,4} & a_ {3,5} & a_ {3,6} \
a_ {4,3} & a_ {4,4} & a_ {4,5} & a_ {4,6} \
a_ {5,3} & a_ {5,4} & a_ {5,5} & a_ {5,6} \
a_ {6,3} & a_ {6,4} & a_ {6,5} & a_ {6,6} \
end {array}
right) \
end {array} $

How do I import an NxN matrix from CSV data?

I'm sorry to bother you with such a trivial problem, but I can not stand it!

I'm trying to import some data from a CSV file into a 64×64 matrix. Each value in my CSV file has a different field.
I tried to import ["file.csv", "table"], but I have not received the 64 columns only 64 lines with really big values.
I also tried to import ["file.csv", "table", "FieldSeparators" -> ";"], but still did not work.
So right now I'm landing on a 64×1 matrix with really big lines and I do not really understand why.

EDIT1: I noticed that I made a mistake there. I meant 128×128, but does not change much. Here is a picture of the datasheet that I use
Enter image description here

linear algebra – maximum of the determinant of the nxn matrix with elements 0 and 1

Generalize from https://math.stackexchange.com/questions/3265627/largest-value-of-a-third-order-determinant-whose-elements-are-0-or-1 I would like to suggest two related issues

(a) Determine the maximum value of the determinant of $ n times n $Matrix whose elements are $ 0 $ or $ 1 $ (christianized here a 0-1 matrix).

(b) Find all possible values โ€‹โ€‹of the determinants of a 0-1 order matrix $ n $,

I found the solutions for small ones $ n = 2, …, 5 $ by brute force in Mathematica, by listing only the values โ€‹โ€‹of the determinants that are all possible $ 2 ^ {n ^ 2} $ Matrices.

I could not go beyond that on my PC $ n = 5 $ due to lack of storage.

I have two ask

1) Does anyone know an analytical solution?

2) Can you improve the Mathematica code, which I will soon show in a self-response? (This part is deliberately delayed, so that the reader finds his own solutions.)

Computer vision – what effects does the mid and median filter with an nxn kernel (neighborhood) have on the grayscale of the image?

Thank you for providing a response to the Computer Science Stack Exchange!

  • Please be sure answer the question, Provide details and share your research!

But avoid

  • Ask for help, clarification or answers to other answers.
  • Make statements based on opinions; secure them with references or personal experiences.

Use MathJax to format equations. Mathjax reference.

For more information, see our tips for writing great answers.

Solve Equation – How do I solve a system of nxn with ci {i, 1, n} unknown coefficients in Mathematica?

I'm new to Mathematica, I've tried to implement this:

                        Delete everything["Global`*",Subscript]

     n = 5; P = 0; F = 1 + sum[Subscript[c, i]* x ^ i, {i, 1, n}];


R = !  (
 * SubscriptBox[([PartialD]),  (x )]F ) - F-P;

Do[S[i_]: = !  (
 * SubsuperscriptBox[([Integral]),  (0 ),  (1 )] ( (( ((R *
 * SubscriptBox[([PartialD])
SubscriptBox[(c), (i)]]R) . /. x -> t) ) [DifferentialD]t ) ), {i, 1, n}]NSolve[{S[i]== 0}, {index[c, i], {i, 1, n}}, reals]/.Rule->Set


Expand[F]

My problem solving the system does not work?

Algorithms – Find disjoint paths between any number of cell pairs marked in the nXn matrix

What should an algorithm be to find all the separate paths between any number of cell pairs specified in the matrix?

We will say that two paths do not intersect if no cell is common between two paths.

My approach is: I will select the first cell pair and create a path between them. Now it will act as an obstacle to the path between other cell pairs. But the problem is how to first select which cell pair? Because there will be problems in finding paths between some cell pairs in the future.

Determinant of this NxN matrix

To let $ nu $ the minimum integer that satisfies $ 2sin ( frac { pi nu} {2 (N + 1)})> tau $for N an integer and $ tau $ any positive number. Since the LHS is limited and RHS is not, there may be cases where no such value of $ nu $ to satisfy the inequality exists. In this case we take with us $ nu = 0 $,
Now consider the polynomial ๐Ÿ™$ a = tau ^ 2-2) $
$$ sum_ {i = 1} ^ { nu-1} ac_ {i} ^ 2- sum_ {i = nu} ^ {N} ac_ {i} ^ 2 + 2 sum_ {i = 1} ^ { nu-2} c_ {i} c_ {i + 1} + 2ic _ { nu} c _ { nu-1} -2 sum_ {i = nu} ^ {N} c_ {i} c_ {i + 1} $$

Suppose I want to express that above as $ c ^ {T} Ac $ With $ c ^ {T} = begin {matrix}
(c_ {1} & c_ {2} … & c_ {N})
end {matrix} $

I want to compute the NxN determinant of A:

$$ begin {matrix}
a & 1 & 0 & 0 ….. & 0 \
1 & a & 1 & 0 ……. & 0 \
0 & 1 & a & 1 ……. & 0 \
0 & 0 & 1 & a ….. \
, \
, \
0. \
end {matrix}
$$

So we repeat blocks of $ begin {matrix}
a & 1 \
1 & a
end {matrix} $
until the $ ( nu-2) ^ {th} $ Row and similar repeating blocks of $ begin {matrix}
-a & -1 \
-1 & -a \
end {matrix} $
of the $ ( nu + 1) ^ {th} $ Row and a block $ begin {matrix}
a & I \
I \
end {matrix} $
in that $ ( nu-1) ^ {th} $ and $ ( nu) ^ {th} $ Series. I could not write the matrix here, so I would be very grateful if you check it yourself. As you can imagine, I make this bill $ int _ {- infty} ^ { infty} dc e ^ {- c ^ {T} Ac} $