All Questions

Tagged with
19
votes
12answers
2k views

Is the Matrix Positive-Definite?

Introduction Today we're gonna take care of the bane of first-year linear algebra students: matrix definiteness! Apparently this doesn't yet have a challenge so here we go: Input A \$n\times n\$ ...
22
votes
16answers
3k views

Find the inverse of a 3 by 3 matrix

Challenge Given nine numbers, a, b, c, d, e, f, g, h, i, as input which correspond to the square matrix: $$\mathbf{M} = \begin{pmatrix}a& b& c\\ d& e&...
11
votes
12answers
832 views

Sum of replicated matrices

Given a list of numbers [ a1 a2 ... an ], compute the sum of all the matrices Aᵢ where Aᵢ is defined as follows (m is the maximum of all aᵢ): ...
22
votes
17answers
2k views

Generate a Walsh Matrix

A Walsh matrix is a special kind of square matrix with applications in quantum computing (and probably elsewhere, but I only care about quantum computing). Properties of Walsh matrices The ...
22
votes
13answers
2k views

Codegolf the Hafnian

The challenge is to write codegolf for the Hafnian of a matrix. The Hafnian of an 2n-by-2n symmetric matrix ...
16
votes
19answers
3k views

Hermitian matrix?

Note that this challenge requires no handling or understanding of complex numbers. Given a non-empty square matrix where every element is a two-element (Re,Im) integer list, determine (giving any ...
23
votes
27answers
2k views

Generalized matrix trace

Inspiration. Given (by any means): A two-argument (or single argument consisting of a two-element list) black box function, f: ℤ+ × ℤ+ → ℤ+ (input and output are ...
26
votes
29answers
2k views

Rotation summation

Take a square matrix containing positive integers as input, and calculate the "rotated sum" of the matrix. Rotated sum: Take the sum of the original matrix and the same matrix rotated 90, 180 and ...
16
votes
7answers
616 views

Queue Our Decomposition

In this challenge I will ask you to find a QR decomposition of a square matrix. The QR decomposition of matrix A is two Matrices Q and R such that A = QR. In particular we are looking for Q to be an ...
3
votes
0answers
81 views

lexicographically sorted list of index [closed]

Given a drawing of the letter shoot system, where an existing piece of pipe is marked with a *, and an empty spot is marked with a ., your task is to compile a lexicographically sorted list of index ...
13
votes
9answers
1k views

Characteristic polynomial

The characteristic polynomial of a square matrix A is defined as the polynomial pA(x) = det(Ix-A) where I is the identity matrix and det the determinant. Note that this definition always gives us a ...
2
votes
1answer
172 views

Advent Challenge 7: Balance the storage carts!

<< Prev Next >> After some careful analysis, Santa was able to determine the dock size ranges and get the presents into the correct transportation dock. Now, he needs you to help him balance ...
34
votes
37answers
3k views

Determinant of an Integer Matrix

Given a square integer matrix as input, output the determinant of the matrix. Rules You may assume that all elements in the matrix, the determinant of the matrix, and the total number of elements in ...
21
votes
9answers
2k views

Is the group cyclic?

Introduction You can skip this part if you already know what a cyclic group is. A group is defined by a set and an associative binary operation $ (that is, ...
17
votes
21answers
1k views

Sum the deltas of my matrix

Background The deltas of an array of integers is the array formed by getting the differences of consecutive elements. For example, [1, 2, 4, 7, 3, 9, 6] has the ...
3
votes
15answers
627 views

Draw diagonal positions of me squared

Based on the interpretation user @ThePirateBay made from the first version of my own challenge Output diagonal positions of me squared now I challenge you to make ASCII art that draws diagonal lines ...
18
votes
21answers
1k views

Output diagonal positions of me squared

Given a number n, Output an ordered list of 1-based indices falling on either of the diagonals of an n*n square matrix. ...
14
votes
23answers
742 views

Compute the Matrix-Vector

Given an integer array of at least two elements, output the Matrix-Vector (defined below) of the array. To compute the Matrix-Vector, first rotate through the size-...
31
votes
26answers
2k views

Sum of first row and column, then second row and column … and so on

Take a non-empty matrix / numeric array containing positive integers as input. Return, in this order, the sums of the first row and column, then the second row and column and continue until there aren'...
19
votes
20answers
1k views

Sum the diagonals

Take a matrix of positive integers as input, and output the individual sums of the elements on the diagonal lines through the matrix. You shall only count the lines that goes diagonally down and to ...
18
votes
2answers
421 views

Is magic possible?

A magic square is an n-by-n square grid, filled with distinct positive integers in the range 1,2,...n^2, such that each cell contains a different integer and the sum of the integers in each row, ...
21
votes
16answers
2k views

Verify Eigenpairs

In this challenge, you will be given a square matrix A, a vector v, and a scalar λ. You will ...
15
votes
5answers
559 views

Find the submatrix with the smallest mean, 2.0

You're given a n-by-m matrix of integers, where n,m > 3. Your task is to find the 3-by-3 sub-matrix that has the lowest mean, and output this value. Rules and clarifications: The integers will be ...
21
votes
14answers
1k views

Find the submatrix with the smallest mean

You're given a n-by-m matrix of integers, where n,m > 3. Your task is to find the 3-by-3 sub-matrix that has the lowest mean, and output this value. Rules and clarifications: The integers will be ...
26
votes
10answers
3k views

Symbolic matrix multiplication

There are lots of different ways to explain matrix multiplication. I'll stick with a single figure since I believe most people here are familiar with it (and the figure is very descriptive). If you ...
12
votes
9answers
605 views

Construct a Gaussian Matrix

Gaussian blur is a method used for blurring images smoothly. It involves creating a matrix which will be used by convolving it with the pixels of an image. In this challenge, your task is to construct ...
13
votes
18answers
2k views

Do Matrix Multiplication!

In mathematics, matrix multiplication or the matrix product is a binary operation that produces a matrix from two matrices. The definition is motivated by linear equations and linear transformations ...
9
votes
3answers
430 views

Code golf a random orthogonal matrix

An orthogonal matrix is a square matrix with real entries whose columns and rows are orthogonal unit vectors (i.e., orthonormal vectors). This means that M^T M = I, where I is the identity matrix ...
26
votes
9answers
3k views

Calculate the permanent as quickly as possible

The challenge is to write the fastest code possible for computing the permanent of a matrix. The permanent of an n-by-n matrix ...
19
votes
12answers
3k views

Codegolf the permanent

The challenge is to write codegolf for the permanent of a matrix. The permanent of an n-by-n matrix ...
21
votes
17answers
5k views

Dijkstra's Challenge

Presented in honor of APL as an interactive tool turning 50 this year Background Ken [Iverson] presented his paper Formalism in Programming Languages in August 1963 at a Working Conference on ...
10
votes
13answers
358 views

Dot Product of Diagonals

This challenge is very simple. You are given as input a square matrix, represented in any sane way, and you have to output the dot product of the diagonals of the matrix. The diagonals in specific ...
18
votes
5answers
793 views

Jordan Decomposition

Important note: Because this challenge only applies to square matrices, any time I use the term "matrix", it is assumed that I am referring to a square matrix. I am leaving off the "square" ...
13
votes
8answers
1k views

Matrix Trigonometry

Introduction The two most common trigonometric functions, sine and cosine (or sin and ...
11
votes
7answers
1k views

Calculate the Kronecker Product

Related, but very different. In the examples below, A and B will be 2-by-2 matrices, and the matrices are one-indexed. A ...
9
votes
10answers
684 views

Find the Matrix Power

Problem Create a program or function that can calculate the result of a matrix raised to the nth power. Your code will take an arbitrary square matrix A and a non-negative integer n, and return a ...
16
votes
8answers
840 views

Transform a matrix

Write a program or function where a matrix A (maximum value of dimensions of the matrix is 100) is transformed to a new matrix B. Each element of the new matrix B is the sum of the positive neighbors ...
25
votes
17answers
976 views

Vandermonde Determinant

Given a vector of n values (x1,x2,x3,...,xn) return the determinant of the corresponding Vandermonde matrix. This determinant ...
43
votes
84answers
5k views

Construct the Identity Matrix

The challenge is very simple. Given an integer input n, output the n x n identity matrix. The identity matrix is one that has <...
16
votes
5answers
602 views

Cofactor Matrices

The cofactor matrix is the transpose of the Adjugate Matrix. The elements of this matrix are the cofactors of the original matrix. The cofactor (i.e. the element of the cofactor matrix at row i and ...
15
votes
12answers
660 views

Construct a companion matrix

You have a number of polynomials who are lonely, so make them some companions (who won’t threaten to stab)! For a polynomial of degree n, there is an ...
8
votes
1answer
1k views

Reduced Row-Echelon Form of a Matrix

The goal of this challenge is to create a program that takes in a matrix and outputs its reduced row-echelon form. A matrix is in reduced row-echelon form if it meets all of the following ...
-3
votes
1answer
454 views

Find the inverse of a matrix

Write a full program to calculate the inverse of a 4-by-4 matrix. Rules The sixteen values of the initial matrix must be hard-coded to variables, as follows: ...
11
votes
3answers
1k views

Solve a 2x2 Eigensystem

For those with a little linear algebra background, the challenge is as simple as this: determine the eigenvalues and eigenvectors of a given complex 2x2 matrix. You may skip ahead to The Challenge for ...
17
votes
10answers
498 views

Ascending matrix

The "ascending matrix" is an infinite matrix of whole numbers (0 included) in which any element is the smallest available element which has not been previously used on the respective row and column: <...
6
votes
9answers
4k views

matrix determinant [closed]

Calculate the determinant of an n x n matrix. Rules read matrix from standard input write to standard output do not use ready solutions from library or language input: columns separated by any ...