How to create inverse matrix with echelon form? Basis of subspace - matrix

I need your help with 2 tasks. I totally do not know how to do them.
For matrix A, find the inverse matrix by fetching to echelon form. Use the block matrix() function to connect the matrices. Matrix is:
1 3 0 -1
0 2 1 3
3 1 2 1
-1 2 0 3
Consider a subspace S generated by vectors:
v1=[1,0,3],v2=[0,2,2],v3=[1,-2,0].
Are they a basis of the subspace S?
I need code, because I haven't got a clue how to do that. Please, help

Related

Algorithm for read matrixes

An algorithm that need process a matrix n x m that is scalable.
E.g. I have a time series of 3 seconds containing the values: 2,1,4.
I need to decompose it to take a 3 x 4 matrix, where 3 is the number of elements of time series and 4 the maximum value. The resulting matrix that would look like this:
1 1 1
1 0 1
0 0 1
0 0 1
Is this a bad solution or is it only considered a data entry problem?
The question is,
do I need to distribute information from each row of the matrix for various elements without losing the values?

How to solve 5 * 5 Cube in efficient easy way

There is 5*5 cube puzzle named Happy cube Problem where for given mat , need to make a cube .
http://www.mathematische-basteleien.de/cube_its.htm#top
Its like, 6 blue mats are given-
From the following mats, Need to derive a Cube -
These way it has 3 more solutions.
So like first cub
For such problem, the easiest approach I could imagine was Recursion based where for each cube, I have 6 position , and for each position I will try check all other mate and which fit, I will go again recursively to solve the same. Like finding all permutations of each of the cube and then find which fits the best.So Dynamic Programming approach.
But I am making loads of mistake in recursion , so is there any better easy approach which I can use to solve the same?
I made matrix out of each mat or diagram provided, then I rotated them in each 90 clock-wise 4 times and anticlock wise times . I flip the array and did the same, now for each of the above iteration I will have to repeat the step for other cube, so again recursion .
0 0 1 0 1
1 1 1 1 1
0 1 1 1 0
1 1 1 1 1
0 1 0 1 1
-------------
0 1 0 1 0
1 1 1 1 0
0 1 1 1 1
1 1 1 1 0
1 1 0 1 1
-------------
1 1 0 1 1
0 1 1 1 1
1 1 1 1 0
0 1 1 1 1
0 1 0 1 0
-------------
1 0 1 0 0
1 1 1 1 1
0 1 1 1 0
1 1 1 1 1
1 1 0 1 0
-------------
1st - block is the Diagram
2nd - rotate clock wise
3rd - rotate anti clockwise
4th - flip
Still struggling to sort out the logic .
I can't believe this, but I actually wrote a set of scripts back in 2009 to brute-force solutions to this exact problem, for the simple cube case. I just put the code on Github: https://github.com/niklasb/3d-puzzle
Unfortunately the documentation is in German because that's the only language my team understood, but source code comments are in English. In particular, check out the file puzzle_lib.rb.
The approach is indeed just a straightforward backtracking algorithm, which I think is the way to go. I can't really say it's easy though, as far as I remember the 3-d aspect is a bit challenging. I implemented one optimization: Find all symmetries beforehand and only try each unique orientation of a piece. The idea is that the more characteristic the pieces are, the less options for placing pieces exist, so we can prune early. In the case of many symmetries, there might be lots of possibilities and we want to inspect only the ones that are unique up to symmetry.
Basically the algorithm works as follows: First, assign a fixed order to the sides of the cube, let's number them 0 to 5 for example. Then execute the following algorithm:
def check_slots():
for each edge e:
if slot adjacent to e are filled:
if the 1-0 patterns of the piece edges (excluding the corners)
have XOR != 0:
return false
if the corners are not "consistent":
return false
return true
def backtrack(slot_idx, pieces_left):
if slot_idx == 6:
# finished, we found a solution, output it or whatever
return
for each piece in pieces_left:
for each orientation o of piece:
fill slot slot_idx with piece in orientation o
if check_slots():
backtrack(slot_idx + 1, pieces_left \ {piece})
empty slot slot_idx
The corner consistency is a bit tricky: Either the corner must be filled by exactly one of the adjacent pieces or it must be accessible from a yet unfilled slot, i.e. not cut off by the already assigned pieces.
Of course you can ignore to drop some or all of the consistency checks and only check in the end, seeing as there are only 8^6 * 6! possible configurations overall. If you have more than 6 pieces, it becomes more important to prune early.

fortran library for sparse matrix multiplication

I have a large matrix which I have stored in the following format, given the matrix A;
A =
1 0 3
5 1 -2
0 0 7
3 vectors;
NVPN = [1 3 4 7] - I arbitrarily put a 1 in the first column, then from the second onwards it is a cumulatively summing the number of non-zero elements per column.
NNVI = [1 2 2 1 2 3] - row index of each non-zero element.
CONT = [1 5 1 3 -2 7] - value of each non-zero element.
I now need to perform matrix*matrix multiplication and matrix*vector multiplication. Does anyone know if the are any FORTRAN libraries, which I can amend to fit my problem, to do this above?
Thanks in advance
The MATMUL function allows you to perform matrix products, which is defined in the section 13.7.70 of the FORTRAN 90 standard. See also: GCC reference.
There is already a topic on sparse matrix libraries here.

General matrix definition for image filtering or trasnformation

I am looking for matrices I can generate to transform other matrices, but I am not talking about regular matrices like:
From this question: The canonical examples you'll find everywhere are non-gaussian box blur:
1 1 1
1 1 1
1 1 1
Image sharpening:
0 -1 0
-1 5 -1
0 -1 0
Edge detection:
0 1 0
1 -4 1
0 1 0
and emboss:
-2 -1 0
-1 1 1
0 1 2
Those are for applying to each region of an image, I just want a big matrix. Is that possible?
For example: A 2560*2560 matrix that I can multiply directly with an image of 2560*2560 pixels.
Yes it's possible, but maybe not in the way you would think. Take a look at the Gaussian blur example at http://scipy-lectures.github.io/intro/scipy.html#fast-fourier-transforms-scipy-fftpack
The thing is that convolution in the image is equivalent to multiplication in the frequency domain. This is the Convolution Theorem from Fourier Transforms (https://en.wikipedia.org/wiki/Fourier_transform#Convolution_theorem). So, it is possible -- and in fact for huge images like you're talking about it should be faster. But the matrices are no longer simple ones like the examples you posted above.

Datalog-find duplicates

I would like to create a constraint that filters all duplicate rows in a nxn matrix, where every field consists of either 0 or 1. The matrix can be up to 10x10 rows and columns.
E.g. we have the following 4x4 matrix:
0 1 0 1
1 1 1 0
0 1 0 1
1 0 1 1
Then row 1 and row 3 would be identical which should not be possible. I've been thinking for 4 hours now about this problem, but with no luck.
Can someone give me a hint please?
As you're note, you can't "just" get the row (1,0,1,1) to occur twice in a datalog relation. The issue is, of course, that datalog relations store sets as opposed to lists or multisets of elements. The best way to deal with this is to add extra data to track either how often a row occurs to treat the matrix as map from indices to values. You might try one for the following:
myUnorderedMultiset[x,y,z,w]=count -> int(x), int(y), int(z), int(w), int(count).
or
myMatrix[rowIndex, columnIndex] = value -> int(rowIndex), int(columnIndex), int(value).

Resources