## What is topology of all Square matrices such that matrix times it transpose is diagonal

What is the topology of the subspace $$X_n\subset M_n(\mathbb R)$$ consisting of all non-zero $$n\times n$$ matrices $$A$$ such that $$A^t A$$ is diagonal ? For example $$X_2$$ is the product of a torus and an interval. Is $$X_n$$ a manifold ? Reference sought.

## Transpose a row in a DataFrame into a binary matrix

Context

Lets say I have a pandas-DataFrame like this:

>>> data.head()                             values  atTime date         2006-07-01 00:00:00+02:00   15.10   0000 2006-07-01 00:15:00+02:00   16.10   0015 2006-07-01 00:30:00+02:00   17.75   0030 2006-07-01 00:45:00+02:00   17.35   0045 2006-07-01 01:00:00+02:00   17.25   0100 

atTime represents the hour and minute of the timestamp used as index. I want to transpose the atTime-column to a binary matrix (making it sparse is also an option), which will be used as nominal feature in a machine learning approach.

The desired result should look like:

>>> data.head()                             values  0000  0015  0030  0045  0000 date         2006-07-01 00:00:00+02:00   15.10   1     0     0     0     0 2006-07-01 00:15:00+02:00   16.10   0     1     0     0     0 2006-07-01 00:30:00+02:00   17.75   0     0     1     0     0 2006-07-01 00:45:00+02:00   17.35   0     0     0     1     0 2006-07-01 01:00:00+02:00   17.25   0     0     0     0     1 

As migth be anticipated, this matrix will be much larger.

My question

I can achieve the desired result with workarounds using apply and using the timestamps in order to create the new columns beforehand.

However, is there a build-in option in pandas (or via numpy, concidering atTime as numpy-array) to achieve the same without a workaround?

## Matrix Inversion in the complexity class $P$ seen as a decision problem

If the set $$P$$ is defined as the set of decision problems that can be solved by a deterministic Turing Machine in polynomial time, and matrix inversion using Gaussian elimination is $$O (n^3)$$, then how can I relate these two concepts to conclude that inverting a matrix is in $$P$$?

I suppose I need a way of converting a description of Gaussian elimination into a decision problem? Or maybe I am confused about the fundamentals

## Multiple vectors to block diagonal matrix

I was reading somewhere and I found this.

Given a set of 1 X M dimension row vectors ai, where 1 <= i <= N. Now B is a block diagonal matrix given by,

B = diag{ a1, a2….., aN }

which is of N X NM dimension.

Can someone please tell me how this matrix B is constructed.

## Matrix inversion of the Kronecker product of matrices

How can I compute the inverse of $$U=\lambda\mathbb{I}-(S\otimes S)^T(S\otimes S)$$ matrix, where $$S$$ is an $$N\times M$$ matrix using something like rank-one update?

I must remove the $$i$$-th row of $$S$$ in a loop over its rows and recompute the inverse of $$U$$. It would be computationally very expensive since $$N\ggg1$$. Can anybody suggest a way to just with some kind of rank-one update I will be able to compute $$U^{-1}$$? For instance using some kind of a Sherman-Morrison-Woodbury formula, similar to this paper in equations (51) to (54).

## How to create a matrix from a generating set

I am trying to form a matrix using a generating set, some v1, v2, v3. I want the code to use the vectors in the set and create a matrix with the zero vector, each of the row vectors, and the combinations v1+v2, v1+v3, v2+v3 and v1+v2+v3, ie. all the possible linear combinations with 0 and 1 as coefficients. This is my first time coding and I feel like this should be doable, but I cannot seem to figure it out.

I’ve tried using for loops, but I end up with repeats. I’ve also been able to do it by doing each of the operations but this isn’t feasible for generating sets with many vectors.

## How to use known Projection Matrices of cameras to generate new fundamental matrix located correctly in 3D space?

I have a few cameras which have been calibrated (using a checkerboard) so I know the fundamental matrix between an origin camera and each remaining camera

I wish to take pairs of camera with no fundamental matrix – but each has a projection matrix – and calculate the fundamental matrix with the view to reconstruct the stereo pair in 3D. To clarify – as all cameras have a projection matrix – I should be able to take any combination and generate a Fundamental matrix – so I can reconstruct and combine stereo pairs in 3D using as many pairs as possible

currently I use this formula:

(decomposing Projection matrices from camera to get C)

but that didn’t quite work with stereo pairs that don’t include the origin. I noticed that to calculate the fundamental matrix that rotation was relative so I added the relative rotation formula when recalculating P from K/R/T (intrinsic camera params, Rotation matrix, Translation matrix)

but now each reconstruction appears on the camera position (I think) instead of all stereo pairs being mapped into same space to give a dense reconstruction

Does anyone know what I am doing wrong? thanks for any help

## Rotate matrix clockWise and counter clockWise

This code is a mix of the same question one time rotating to the right and one time to the left. I tried to simplify the code since I’m struggling with all of the indexing here.

https://leetcode.com/problems/rotate-image/

https://www.geeksforgeeks.org/rotate-matrix-90-degree-without-using-extra-space-set-2/

Rotate the image by 90 degrees (clockwise).

Note:

You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation.

Example 1:

Given input matrix = [ [1,2,3], [4,5,6], [7,8,9] ],

rotate the input matrix in-place such that it becomes: [ [7,4,1],
[8,5,2], [9,6,3] ] Example 2:

Given input matrix = [ [ 5, 1, 9,11], [ 2, 4, 8,10], [13, 3, 6, 7], [15,14,12,16] ],

rotate the input matrix in-place such that it becomes: [ [15,13, 2, 5], [14, 3, 4, 1], [12, 6, 8, 9], [16, 7,10,11] ]

Please review this code as I am trying to simplify it in order to be able to have a good short solution for a coding interview. I can’t memorize this logic of course I just want to have a solid simple solution in mind.

using Microsoft.VisualStudio.TestTools.UnitTesting;  namespace ArrayQuestions {     /// <summary>     /// https://www.geeksforgeeks.org/inplace-rotate-square-matrix-by-90-degrees/     /// </summary>     [TestClass]     public class RotateMatrix90     {         [TestMethod]         public void RotateClockWise2x2Test()         {             int[][] mat =             {                 new[]{0,1},                 new[]{2,3},             };             int[][] expected =             {                 new[]{2,0},                 new[]{3,1}             };             RotateClockWise(mat);             int size = mat.GetLength(0);             for (int r = 0; r < size; r++)             {                 for (int c = 0; c < size; c++)                 {                     Assert.AreEqual(expected[r][c], mat[r][c]);                 }             }         }           [TestMethod]         public void RotateClockWise3x3Test()         {             int[][] mat =             {                 new[]{1, 2, 3},                 new[]{4, 5, 6},                 new[]{7, 8, 9}             };             //tranpose then flip horizotally             //1,4,7             //2,5,8             //3,6,9             int[][] expected =             {                 new[]{7, 4, 1},                 new[]{8, 5, 2},                 new[]{9, 6, 3}             };             RotateClockWise(mat);             int size = mat.Length;             for (int r = 0; r < size; r++)             {                 for (int c = 0; c < size; c++)                 {                     Assert.AreEqual(expected[r][c], mat[r][c]);                 }             }         }         [TestMethod]         public void RotateCounterClockWise2x2Test()         {             int[][] mat =             {                 new[]{0,1},                 new[]{2,3},             };              //0,2             //1 3             int[][] expected =             {                 new[]{1,3},                 new[]{0,2}             };             RotateCounterClockWise(mat);             int size = mat.GetLength(0);             for (int r = 0; r < size; r++)             {                 for (int c = 0; c < size; c++)                 {                     Assert.AreEqual(expected[r][c], mat[r][c]);                 }             }         }          [TestMethod]         public void RotateCounterClockWise3x3Test()         {             int[][] mat =             {                 new[]{1, 2, 3},                 new[]{4, 5, 6},                 new[]{7, 8, 9}             };             //tranpose then flip horizotally             //1,4,7             //2,5,8             //3,6,9             int[][] expected =             {                 new[]{3, 6, 9},                 new[]{2, 5, 8},                 new[]{1, 4, 7}             };             RotateCounterClockWise(mat);             int size = mat.Length;             for (int r = 0; r < size; r++)             {                 for (int c = 0; c < size; c++)                 {                     Assert.AreEqual(expected[r][c], mat[r][c]);                 }             }         }         //moving elements clockwise (90 degrees to the right)         public void RotateClockWise(int[][] matrix)         {             Transpose(matrix);             ReverseRows(matrix);         }         //moving elements counter clockwise         public void RotateCounterClockWise(int[][] matrix)         {             Transpose(matrix);             ReverseCols(matrix);         }         private void Transpose(int[][] matrix)         {             int size = matrix.Length;             for (int i = 0; i < size; i++)             {                 for (int j = i; j < size; j++)                 {                     Swap(ref matrix[i][j], ref matrix[j][i]);                 }             }         }          private void ReverseRows(int[][] matrix)         {             for (int i = 0; i < matrix.Length; i++)             {                 for (int j = 0, k = matrix.Length - 1; j < k; j++, k--)                 {                     Swap(ref matrix[i][j], ref matrix[i][k]);                 }             }         }         private void ReverseCols(int[][] matrix)         {             for (int i = 0; i < matrix.Length; i++)             {                 for (int j = 0, k = matrix.Length - 1; j < k; j++, k--)                 {                     Swap(ref matrix[k][i], ref matrix[j][i]);                 }             }         }          void Swap(ref int i, ref int j)         {             int temp = i;             i = j;             j = temp;         }     } } 

## An explicit formula for characteristic polynomial of matrix tensor product

Consider two polynomials P and Q and their companion matrices. It seems that char polynomial of tensor product of said matrices would be a polynomial with roots that are all possible pairs product of roots of P,Q.

I guess its coefficients could be expressed through coefficients of P and Q. But I don’t know the explicit formula and I cannot find it. I also failed to find it out myself — I tried different approaches. Maybe it should be that characteristic polynomial, maybe resultant of some form, but..

I hope this is done by someone already.

## How to scatter plot from matrix with many y-axes values for each x-axes value?

Consider matrix

A = {{0, 2.54343, 3.566, 4.2323, 2.3434}, {0.1, 6.432, 4.6465, 5.656,  1.34},  {0.2, 0.3423, 1.6342, 3.323, 2.04}}; 

X-axes values are 0, 0.1, 0.2.

Their are 4 y-axes values for each x-axes data point

How to plot this?

Naive use of

ListPlot[A] 

fails.