11
votes
Nonnegative Least Squares Algorithm (NNLS)
We can compare 6 algorithms based on FindMinimum,NMinimize, ConvexOptimization, ...
11
votes
Is it possible to use the DGEEV and DSYEV LAPACK subroutines in Mathematica?
You can use LibraryLink to call LAPACK directly. It involves however quite a lot of boilerplate code. Here is an example:
...
8
votes
Accepted
How to obtain independent variables from a set of linear constraints
First one can set up and solve the system.
...
7
votes
How to replace anti diagonal elements of a matrix
From The Procedural Dodo:
If you can do it in place (destroying the orginal m), this will be fast:
...
7
votes
Accepted
Matrix Integro-differential equation
The problem can easily be solved after reformulation to a system of ODEs. Let us start with
$$
\frac{d\rho}{dt}=-i[H_{0}(t),\rho(t)]-A^{2}\Big[H_{1},\int_{t1}^{t}e^{-B(t-s)}\Big(e^{-i\int_{s}^{t}H_{0}(...
5
votes
How to export a matrix in mathematica to some format so that I can read it in python using numpy array
One easy way is python pickle; before that, we should convert your data to a format readable by sympy. here are the steps:
...
5
votes
5
votes
Accepted
How to replace anti diagonal elements of a matrix
This is the kind of question that might trigger the "how-many-ways-can-you-do-it" game. I'll kick it off with this:
...
5
votes
Accepted
Does converting large 3D matrices to VERY large 2D matrices affect speed of operations done on the matix?
There's no appreciable difference in memory usage, for either unpacked or for packed arrays:
...
4
votes
Finding eigenvectors of a symbolic matrix
Here is one, not particularly sophisticated, approach using Normalize. You could use
evs = Map[Normalize,Eigenvectors[{{a,b},{b,-a}}]];
to get normalized ...
4
votes
How to replace anti diagonal elements of a matrix
We can subtract the anti-diagonal to remove it and then add the Reverse of diagonal.
...
4
votes
How can I generate a tridiagonal block matrix?
It must be many ways to do this,here we provide one way.
...
3
votes
How to create a matrix with multiple variables defining the elements?
Array[f,{3,3,3,3},{0,0,0,0}]
will give you a 4-dimensional matrix.
f@@@Tuples[{0,1,2},4]
will give you a 1-dimensional list.
...
3
votes
How to find the index of a square matrix in Mathematica quickly?
In version 13.0.1, there is a undocumentation function LinearAlgebra`MatrixIndex. But I'm not sure when this is introduced
...
3
votes
Accepted
Convert List to Matrix
Clear["Global`*"]
(mat = RandomInteger[200, {3, 3}]) // MatrixForm
Note that the MatrixForm wrapper is isolated ...
3
votes
Solution to a linear equation with minimum rank
Your transposed equation looks like Transpose[M].Transpose[X]==Transpose[A]
LeastSquares finds the minimal solution
...
3
votes
How to replace anti diagonal elements of a matrix
idm = IdentityMatrix[Length@m]
(res = Reverse /@ (m idm) + m (-(Reverse /@ idm ) + 1)
) // MatrixForm
$$\left(
\begin{array}{ccccc}
100 & 9 & 3 & 8 &...
3
votes
How to replace anti diagonal elements of a matrix
use element-wise operation.
keep the diag-matrix and reverse it.
anti = mat //
Diagonal // (*take diag*)
DiagonalMatrix // (*make mat*)
Map[Reverse] (*rev it*)
{...
3
votes
Accepted
How can I have Mathematica solve the curve equation when nested functions are involved?
You would have to come up with a model in order to fit those curves. No automated system can do that for you. However, that may not be the most useful approach. For instance some properties of the ...
2
votes
How to replace anti diagonal elements of a matrix
Making use of the method posted by ciao (in an answer to How to zero (or replace) the diagonal of a square matrix?)
...
2
votes
How to replace anti diagonal elements of a matrix
With[
{mask =
Reverse[ReplaceAll[DiagonalMatrix[Function /@ Diagonal[m]], 0 -> Identity], 2]},
MapThread[Construct, {mask, m}, 2]]
2
votes
Solution to a linear equation with minimum rank
We can use Nonnegative Least Squares Algorithm (NNLS) discussed here to solve matrix equation X.M=A with constraints ...
2
votes
How can I generate a tridiagonal block matrix?
The matrix you have is block tridiagonal and block Toeplitz.
I'll give two methods: one that uses nothing but documented functionality, and one that uses undocumented functionality.
First up is an ...
1
vote
Accepted
Generalised KroneckerProduct that works like Outer[]
I'm not sure what to make of your KroneckerProduct comment, but I think what you're looking for is MapThread:
MapThread[f, {matA, matB}, 2]
1
vote
Regression of a set of (2-element) vectors on another set of (2-element) vectors
I think you have three problems that get in the way of what I think you're asking. I think you want to perform a regression on the following model (which also isn't the model I think you should be ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
matrix × 3168linear-algebra × 741
list-manipulation × 625
performance-tuning × 217
equation-solving × 186
eigenvalues × 144
plotting × 128
functions × 112
sparse-arrays × 111
symbolic × 99
tensors × 88
vector × 82
array × 78
table × 77
graphs-and-networks × 65
replacement × 65
differential-equations × 64
random × 64
mathematical-optimization × 62
numerics × 59
function-construction × 58
simplifying-expressions × 57
calculus-and-analysis × 50
programming × 45
physics × 41