Questions tagged [linear-algebra]
For challenges involving linear algebra, the mathematics of vector spaces and linear mappings between them.
57 questions
19
votes
7
answers
2k
views
Seven-dimensional cross product
The cross product is a peculiarly 3-dimensional phenomenon. There are multiple ways of generalizing it, but each of them have trade offs.
If you require that a cross product be a product of two ...
10
votes
4
answers
268
views
Inequality region vertices with 4 equations
Given the following inequalities:
$$
\begin{align}
ax+by&\leq c\\
dx+ey&\leq f\\
gx+hy&\leq i\\
jx+ky&\leq l
\end{align}
$$
These inequalities enclose a region in the shape of a convex ...
14
votes
19
answers
3k
views
Antiparallel 12-hour Clock Hands
Output (or print) each of the 11 times, one per line, in the POSIX %I:%M:%S format, at which the hour and minute hands of a 12-hour clock are antiparallel. Here <...
4
votes
4
answers
674
views
Fill in matrices for matrix bit flipping as quickly as possible
Consider an n by n binary matrix. If it has rank r <= n, then we want to compute the largest number bits flips necessary to reduce its rank to a specific value. All computations should be done ...
12
votes
7
answers
2k
views
Contract a tensor
Introduction
Tensor contraction is an operation that can be performed on a tensor. It is a generalization of the idea of the trace of a matrix. For example, if we have a rank-2 tensor (a matrix) and ...
1
vote
0
answers
191
views
Produce a secure block cipher round function (1 bit round key; 7 bit message) [closed]
We need to produce a block cipher round function with a 1 bit round key size and a 7 bit message size with the highest level of cryptographic security according to our measure of security.
...
27
votes
42
answers
2k
views
Diagonalize a vector
Diagonalize a vector into a matrix.
Input
A vector, list, array, etc. of integers \$\mathbf{v}\$ of length \$n\$.
Output
A \$n \times n\$ matrix, 2D array, etc. \$A\$ such that for each element \$a_i \...
1
vote
0
answers
141
views
Print all semimagic squares [closed]
I am working on a code to print all semimagic squares [1] of a given size. I am working with the following definition:
An \$n\times n\$ consists of numbers \$1,2,\cdots, n^2\$.
All numbers must be ...
15
votes
13
answers
1k
views
Hankel transform of an integer sequence
A Hankel matrix is a square matrix in which each ascending skew-diagonal from left to right is constant, e.g.:
$$\begin{bmatrix} a & b & c & d \\ b & c & d & e \\ c & d &...
10
votes
1
answer
487
views
Find the linear transformation
Given a set of bit vectors \$A\$ and a binary matrix \$M\$, we can define the set \$MA = \{ Mx : x \in A \}\$, where \$ M x \$ is the result of the matrix multiplication of \$ M \$ by \$ x \$ over \$\...
7
votes
2
answers
531
views
NxM List Combination Closest to Target
Given a list of N lists, each containing M positive integers, and a separate list of M positive integers (target values), return a list of N scalars (integers with a value of 0 or more) that ...
3
votes
3
answers
381
views
Appease the Picky Eater
Your friend Jack is a picky eater. He only likes certain foods, and he only likes to eat a certain amount of them each day. Despite this, Jack has very strict calorie and macronutrient goals that he ...
15
votes
7
answers
827
views
Are these the basis vectors?
A basis of a vector space \$V\$ is a set of vectors \$B\$ such that every vector \$\vec v \in V\$ can be uniquely written as a linear combination of the vectors in \$B\$. In other words, let \$B = \{\...
21
votes
11
answers
3k
views
Is this a Jordan matrix?
Background
A Jordan matrix is a block-diagonal matrix where each block on the diagonal has the structure of
$$
\begin{bmatrix}
\lambda & 1 & 0 & \cdots & 0 \\
0 &...
16
votes
4
answers
881
views
Bad matrix multiplication that gives the right answer
Executive summary:
Print NxN matrices \$A\$ and \$B\$ where \$ AB = 10A + B \$. Largest N wins!
Details:
Entrants in this challenge should choose an N. Submit a program that takes an input integer '...