math

Which method of matrix determinant calculation is this?

This is the approach John Carmack uses to calculate the determinant of a 4x4 matrix. From my investigations i have determined that it starts out like the laplace expansion theorem but then goes on to calculate 3x3 determinants which doesn't seem to agree with any papers i've read. // 2x2 sub-determinants float det2_01_01 = mat[0][0] *...

Converting unix timestamp to YYYY-MM-DD HH:MM:SS.

I have a Unix timestamp that I need to get the individual year, month, day, hour, minute and second values from. I never was very good in math class so I was wondering if you guys could help me out a little :) I have to do everything myself (no time.h functions). The language is C. ...

Matrix classes in c++

I'm doing some linear algebra math, and was looking for some really lightweight and simple to use matrix class that could handle different dimensions: 2x2, 2x1, 3x1 and 1x2 basically. I presume such class could be implemented with templates and using some specialization in some cases, for performance. Anybody know of any simple implement...

iPhone SDK log to base 10

Is there a method for determining the base 10 log of any number in the iPhone language? Any help with the math for this would be appreciated by a newbie budding iPhone developer. Thanks in advance. M ...

Identifying accurate matches from SQL Server Full Text Search

Hello I am using SQL Server 2008 Full Text Search, and joining to the FreeTextTable to determine ranking of results. How do I determine whether the result set is giving an accurate match or not? For example, for one search I may get these results: Manufacturer | Rank =================== LG U300 ------- 102 LG C1100 ------ 54 LG GT50...

Matrix multiplication - view/projection, world/projection, etc

In HLSL there's a lot of matrix multiplication and while I understand how and where to use them I'm not sure about how they are derived or what their actual goals are. So I was wondering if there was a resource online that explains this, I'm particularly curious about what is the purpose behind multiplying a world matrix by a view matri...

When will I run into problems when calculating with double values?

Imagine I write a simple calculator application, that just calculates simple stuff like 1.5 + 30 + 9755 - 30 - 20000 + 999900.54 I remember slightly that there were some precision problems when using floating point numbers. At which point would my calculator app start to create wrong results? Most of the time, I would just calcula...

How do I compute the first decimal digit of a division between large numbers?

I have two unsigned long longs X and Y, where X < Y, but both may be very large. I want to compute the first digit past the decimal point of X / Y. For example, if X is 11 and Y is 14, then 11 / 14 is .785…, so the result should be 7. (X * 10) / Y would work, except it produces the wrong result if X * 10 overflows. Conversion to doub...

Single Precision Math Operations in .NET?

The .NET framework's Math functions mostly operate on double precision floats, there are no single precision (float) overloads. When working with single precision data in a high performance scenario this results in unnecessary casting and also calculating functions with more precision than is required, thus performance is affected to som...

prime generator optimization

I'm starting out my expedition into Project Euler. And as many others I've figured I need to make a prime number generator. Problem is: PHP doesn't like big numbers. If I use the standard Sieve of Eratosthenes function, and set the limit to 2 million, it will crash. It doesn't like creating arrays of that size. Understandable. So now I'...

What is O value for naive random selection from finite set?

This question on getting random values from a finite set got me thinking... It's fairly common for people to want to retrieve X unique values from a set of Y values. For example, I may want to deal a hand from a deck of cards. I want 5 cards, and I want them to all be unique. Now, I can do this naively, by picking a random card 5 t...

How can I achieve a modulus operation with System.TimeSpan values, without looping?

I'm in a very performance-sensitive portion of my code (C#/WPF), and I need to perform a modulus operation between two System.TimeSpan values in the quickest way possible. This code will be running thousands of times per second, and I would very much prefer to avoid using a manual loop calculation - at all costs. The idea of a modu...

How do you translate this for loop into mathematics

I'm trying to solve what seems to be a simple math problem. I can write the problem as a for loop, but I'm not sure how to translate it into an equation. Can anyone help? x = 10; for(int i=0; i<3000; i++) { x = x^2 } ...

Help constructing an OBB, trying to Represent a matrix with 3 vectors

I am presently trying to construct an OBB (Oriented Bounding Box) using the source and math contained in the book "Real Time Collision Detection". One problem with the code contained in this book is that it does very little to explain what the parameters mean for the methods. I am trying to figure out what I need to feed my setOBB() me...

How can I stop OverflowException being thrown on integer division?

Hello World! I am getting OverflowException's thrown at me when I don't want them (or so I think). I am performing some odd calculations where I expect the values to overflow, discarding overflowed bits. It seems I can't get this to work properly though. Basically this is one pair of i and j which happens as I iterate over huge sets (i...

Derive integer factors of float value?

I have a difficult mathematical question that is breaking my brain, my whiteboard, and all my pens. I am working with a file that expresses 2 values, a multiplicand and a percentage. Both of those values must be integers. These two values are multiplied together to produce a range. Range is a float value. My users edit the range, and I ...

find minimum number of vertices in unweighted graph

I have got an undirected weighted connected graph. If I select one vertex I automatically select all the vertices connected directly with it. What will be the algorithm so that I am able to select all the vertices of the graph using minimum number of tries? In each try I select one vertex. For example for adjacency matrix a[][]={1,1,0,0,...

Algorithm that takes 2 'similar' matrices and 'aligns' one to another

First of all, the title is very bad, due to my lack of a concise vocabulary. I'll try to describe what I'm doing and then ask my question again. Background Info Let's say I have 2 matrices of size n x m, where n is the number of experimental observation vectors, each of length m (the time series over which the observations were collect...

Dynamically generating a word cloud?

Ok well heres what I would like to do in PHP: http://www.wordle.net/ I know how to do all of the GD (writing to the canvas), my issue is the logic of actually keeping track of different sized word boxes and correctly placing them on a blank canvas. If anyone knows of a good site that has some resources that could lead me in the right d...

I need to round a value up in vb.net

Hallo I,m developing a debt calculation program 'my problem is when i have to calculate the months to pay back the debt it comes to 28.04 and i have to get it to 29 can some one pls help me out. Thank you in advance my code looks like this: Dim b, SubMtP As Integer Dim outsUm, si outsUm = TextBox1.Text SubMtP = Forma...