Author: admin
Links - 2010 May 27
- Canon EF 50/1.2L USM Review -
- Ubuntu 10.04 Lucid Lynx Benchmarked and Reviewed -
- Testing a rotation axis to drain a 3D workpiece -
- Maple R3 now shipping -
- Aircraft carrier is moving target for autonomous quadcopter -
- Resonances -
- Bspline approximation of circle arc and straight line for pocket machining -
- Simple Toys -
- Converting Microsoft Lifecam Cinema HD Webcam for Telescope Use -
- Rise To Power Fail -
- Google to Apple: The Web Is the Platform; iTunes, Not So Much -
Matrix determinant with Boost::uBLAS
Boost uBLAS provides BLAS functionality, but doesn't have a function for computing the determinant of a matrix. Googling for this turns up a few code snippets, but it's best to document this completely here now since I got it to work, and it will be useful for opencamlib sooner or later.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #include <boost /numeric/ublas/matrix.hpp> #include </boost><boost /numeric/ublas/io.hpp> #include </boost><boost /numeric/ublas/lu.hpp> namespace bnu = boost::numeric::ublas; int determinant_sign(const bnu::permutation_matrix<std ::size_t>& pm) { int pm_sign=1; std::size_t size = pm.size(); for (std::size_t i = 0; i < size; ++i) if (i != pm(i)) pm_sign *= -1.0; // swap_rows would swap a pair of rows here, so we change sign return pm_sign; } double determinant( bnu::matrix<double>& m ) { bnu::permutation_matrix</std><std ::size_t> pm(m.size1()); double det = 1.0; if( bnu::lu_factorize(m,pm) ) { det = 0.0; } else { for(int i = 0; i < m.size1(); i++) det *= m(i,i); // multiply by elements on diagonal det = det * determinant_sign( pm ); } return det; } int main () { bnu::matrix<double> m(3, 3); for (unsigned i = 0; i < m.size1() ; ++i) { for (unsigned j = 0; j < m.size2() ; ++j) { m (i, j) = 3 * i + sqrt(j+1); // fill matrix m(i,j) = m(i,j)*m(i,j); // with some numbers } } std::cout << "before det() call m= " << m << std::endl; double det = determinant(m); std::cout << "after det() call m= " << m << std::endl; // m has changed afted determinant() call! std::cout << "determinant=" << det << std::endl; } |
I'm trying the WP-syntax plugin here for the first time. The include statements are garbled, but otherwise it seems to work.
download source: utst1.cpp
This compiles on Lucid Lynx with the following CMakeLists.txt:
cmake_minimum_required(VERSION 2.6) PROJECT(utst1) find_package( Boost ) if(Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) endif() ADD_EXECUTABLE(utst1 utst1.cpp) target_link_libraries(utst1 ${Boost_LIBRARIES})
Sunday 18k loop
The summer warmth is gone and replaced by a +14C grey drizzle - which is just fine for running.
about 1 min walking breaks every 2 km as described in Galloway's book show up as dips in the HR graph:
MicroMagic 2010 Ranking 3, Lohja
12 boats completed 6 races before lunch in light and shifting conditions. After lunch there was no more sailing because of heavy lightning, thunder, and lots of rain.
The ball-raced gooseneck with ballbearings around the mast looks nice. Riku had a new boat with aluminium mounts for the sheet and rudder servos instead of the standard plywood ones. Many boats had new "VAM" sails.
Thursday Ten
Links - 2010 May 20
- Cramming more pixels into a Thinkpad -
- Guido’s Python: Objects 102 -
- The Design of Design -
- Building an oak telescope -
- 05/14/10 PHD comic: 'Tales from the Laser Beam' -
- The Balancing Cube -
- WordPress 3.0: The 5 Most Important New Features -
- The peril of the Facebook anti-privacy pattern -
- HTC EVO 4G $200, on Sale June 4 -
- How Much Gas Does Your State Use Per Person? -
- Seeing is Believing - Vigna unguiculata
- 05/12/10 PHD comic: 'Ode to the L.A.S.E.R.' -
- Dynamixel Servos Are In 🙂 - has anyone used these for radio sailing ??
Music on the run - cheap
Tried a new MP3 player today: SKU34705 from dealextreme. This 11 $ player ships without a memory card, which will cost about another 11 euros for a 4 Gb micro-SD card. The build quality is not great - but I wasn't expecting too much for 11 $. It works however, and there are no cords since the memory-stick, player, and battery all fit in the back. That does make the headphones a bit more back-heavy than the conventional corded Sennheiser PMX I've used before (39.90eur at the local shop, for only the headphones!). The battery is charged from the USB-port, and the SD-card shows up as a disk-drive in Ubuntu automagically without installing any drivers.
Hope the flu is finally defeated now. 6 k at something close to 5:47/km today did not feel too bad.
Signs of Summer
Last week was mostly flu and occasional fever. Managed a careful 7k jog on Saturday with newly bought Camelbak Fairfax (45eur + postage through amazon.de) . The Finnish retailers (including those at the HCR expo) seem to think that asking 69.90euros is just fine - no thanks!
The Finnish summer is cold but short - the last few days have finally been +20C or warmer. Quite similar to LA in late February.
Those mosquitoes were all hovering in a bunch, usually quite close to a tree branch. Took a lot of photos with a 200mm/F4 lens but with manual focus and shallow depth of focus the yield is low. Not sure what stage in their life-cycle they are in, I don't think they hover in one place and look like this later in the summer. Anyone who is a mosquito-lover care to explain? 🙂
Links - 2010 May 13
- Model for the prediction of 3D surface topography in 5-axis milling -
- Linux Versus E. coli | The Loom -
- Apparently Facebook considers your current IP address to be "public information" as well. -
- INFOGRAPHIC: The History Of Facebook’s Default Privacy Settings -
- Reduce Your 10k, Half or Marathon Race Time -
- Android Sales Surpass iPhone Sales -
- Google I/O 2010 -
- Recycled aluminum – first casting -
- Parallel Programming with Oracle Developer Tools -
- A Call For an Open, Distributed Alternative To Facebook -
- A novel iso-scallop tool-path generation for efficient five-axis machining of free-form surfaces -