linear-algebra

Why doesn't this Blitz++ code compile ?

I'm a blitz++ newbie. So far, so good, but I'm a bit mystified why the commented out line in the code below fails to compile with error: conversion from ‘blitz::_bz_tinyMatExpr<blitz::_bz_tinyMatrixMatrixProduct<double, double, 3, 3, 3, 3, 1, 3, 1> >’ to non-scalar type ‘const m33’ requested I'm on Debian/Lenny (g++ 4.3.2, Blitz 0.9...

How expensive is it to compute the eigenvalues of a matrix?

How expensive is it to compute the eigenvalues of a matrix? What is the complexity of the best algorithms? How long might it take in practice if I have a 1000x1000 matrix? I assume it helps if the matrix is sparse? Are there any cases where the eigenvalue computation would not terminate? In R, I can compute the eigenvalues as in t...

element-wise operations with boost c++ ublas matrix and vector types

i'd like to perform element-wise functions on boost matrix and vector types, e.g. take the logarithm of each element, exponentiate each element, apply special functions, such as gamma and digamma, etc. (similar to matlab's treatment of these functions applied to matrices and vectors.) i suppose writing a helper function that brute-force...

higher order linear regression

I have the matrix system: A x B = C A is a by n and B is n by b. Both A and B are unknown but I have partial information about C (I have some values in it but not all) and n is picked to be small enough that the system is expected to be over constrained. It is not required that all rows in A or columns in B are over constrained. I'm l...

Algorithm for finding nearby points?

Given a set of several million points with x,y coordinates, what is the algorithm of choice for quickly finding the top 1000 nearest points from a location? "Quickly" here means about 100ms on a home computer. Brute force would mean doing millions of multiplications and then sorting them. While even a simple Python app could do that in ...

numpy linear algebra basic help

This is what I need to do- I have this equation- Ax = y Where A is a rational m*n matrix (m<=n), and x and y are vectors of the right size. I know A and y, I don't know what x is equal to. I also know that there is no x where Ax equals exactly y. I want to find the vector x' such that Ax' is as close as possible to y. Meaning that (Ax...

Unprojecting an on screen point back to an isometrically projected world

I am doing a behind the curtains 3d simulation while rendering the world in my 2d isometric engine. I've never done an isometric engine before, and my matrix math is rusty in general so I am having problems. I have a projection matrix, which in its simplest form is this: 0.7 0.35 0 0 -0.87 0 -0.71 0.35 1...

Rejigging a floating point equation ...

I'd like to know if there is a way to improve the accuracy of calculating a slope. (This came up a few months back here). It seems by changing: float get_slope(float dXa, float dXb, float dYa, float dYb) { return (dXa - dXb)/(dYa - dYb); } to float get_slope(float dXa, float dXb, float dYa, float dYb) { return dXa/(dYa - d...

Is there Fortran subroutine in LAPACK/BLAS or somewhere else to calculate LDL decomposition?

Like the title says, I need to form cholesky LDL decomposition for my positive definite matrix A (Like normal cholesky, but there's ones one diagonal of L, and D is diagonal matrix). I have found only one function in Lapack which does that, but it says the matrix A has to be tridiagonal. Is there somekind of function which does that in s...

Array division- translating from MATLAB to Python

I have this line of code in MATLAB, written by someone else: c=a.'/b I need to translate it into Python. a, b, and c are all arrays. The dimensions that I am currently using to test the code are: a: 18x1, b: 25x18, ...

mrdivide function in Matlab- what is it doing and how to do it in Python?

I have this line of code: a/b I am using these inputs: a=[1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9] b=ones(25,18) this is the result: [5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], a 1x25 matrix. what is matlab doing? I am trying to duplicate this behavior in Python, and the mrdivide documentation in matlab was unhelpful. where d...

how to generate pseudo-random positive definite matrix with constraints on the off-diagonal elements?

The user wants to impose a unique, non-trivial, upper/lower bound on the correlation between every pair of variable in a var/covar matrix. For example: I want a variance matrix in which all variables have 0.9 > |rho(x_i,x_j)| > 0.6, rho(x_i,x_j) being the correlation between variables x_i and x_j. Thanks. ...

how to generate pseudo-random positive definite matrix with constraints on the off-diagonal elements?

The user wants to impose a unique, non-trivial, upper/lower bound on the correlation between every pair of variable in a var/covar matrix. For example: I want a variance matrix in which all variables have 0.9 > |rho(x_i,x_j)| > 0.6, rho(x_i,x_j) being the correlation between variables x_i and x_j. Thanks. Ok, something of a quick&di...

ublas vs. matrix template library (MTL4)

I'm writing a software for hyperbolic partial differential equations in c++. Almost all notations are vector and matrix ones. On top of that, I need the linear algebra solver. And yes, the vector's and matrix's sizes can vary considerably (from say 1000 to sizes that can be solved only by distributed memory computing, eg. clusters or sim...

How is linear algebra used in algorithms?

Several of my peers have mentioned that "linear algebra" is very important when studying algorithms. I've studied a variety of algorithms and taken a few linear algebra courses and I don't see the connection. So how is linear algebra used in algorithms? For example what interesting things can one with a connectivity matrix for a graph...

SVG Linear Gradient Scale and Translation Question

I have the following radial gradient: <radialGradient inkscape:collect="always" xlink:href="#linearGradient2454" id="radialGradient2460" cx="4022.8572" cy="5451.2656" fx="4022.8572" fy="5451.2656" r="3559.865" gradientTransform="matrix(-0.1071067,-0.1166362,0.1377765,-7.0459663e-2,276.61943,1452.439)" gradi...

Boost's Linear Algebra Solution for y=Ax

Does boost have one? Where A, y and x is a matrix (sparse and can be very large) and vectors respectively. Either y or x can be unknown. I can't seem to find it here: http://www.boost.org/doc/libs/1_39_0/libs/numeric/ublas/doc/index.htm ...

Compiling C++ Code With Boost's Numeric Binding Library to Solve Ax=b Linear System

I am using Numeric Library Bindings for Boost UBlas to solve a simple linear system: #include<boost/numeric/ublas/matrix.hpp> #include<boost/numeric/ublas/io.hpp> #include<boost/numeric/bindings/traits/ublas_matrix.hpp> #include<boost/numeric/bindings/lapack/gesv.hpp> #include <boost/numeric/bindings/traits/ublas_vector2.hpp> namespac...

C++ Memory Efficient Solution for Ax=b Linear Algebra System

I am using Numeric Library Bindings for Boost UBlas to solve a simple linear system. The following works fine, except it is limited to handling matrices A(m x m) for relatively small 'm'. In practice I have a much larger matrix with dimension m= 10^6 (up to 10^7). Is there existing C++ approach for solving Ax=b that uses memory efficien...

Compiling PARDISO linear solver test case with GCC

I am trying to compile a linear system solver using PARDISO. The test case (pardiso_sym.c) also downloaded from the same website above. I have the following files inside the directory: [gv@emerald my-pardiso]$ ls -lh total 1.3M -rw-r--r-- 1 gv hgc0746 1.3M Aug 7 11:59 libpardiso_GNU_IA64.so -rw-r--r-- 1 gv hgc0746 7.2K Nov 13 2007 p...