Add your own alternative version
Stats
107.1K views 598 downloads 26 bookmarked
Posted
8 Jul 2003

Comments and Discussions



Allow user to perform an incremental search on the dropdown to locate a name. It means the dropdown should allow user to type over and it and find an employee. i need coading/algorthim for this in VB.net





Sorry, but I fail to see what this has to do with my article ...





lets make it simple.....i have to type name in the text box...bellow that text box i need related name from database table.....like if i type "A" means i need suggestion like "Air","apple" etc below the text box...without using asp control and AJAX





Again, this has nothing to do with my article, posting here is inappropriate ...





anybody have this project with user interface?
im new in vb.net and cant use it
help pleaseeeeeeeeeeeeeeeeee





Hi there,
it's a library and thus has no UI. Include the assembly by adding a reference to it in your project.
Cheers,
Yves





Hi, First of all Thanks for the library They are gonna be really useful for me.
However I don't get how to use your functions...I'm leaving here an example If someone could help me I'd be really glad
Public Class hello<br />
<br />
Public Function byebye() As Single<br />
Dim sV1(,) As Single = {{1, 2}, {3, 4}}<br />
Dim sV2(,) As Single<br />
Dim Sol As Single<br />
Sol = Transpose(sV1(2, 2), sV2(, ))<br />
MsgBox(sV2)<br />
End Function<br />
End Class
The thing is that i don't know what to introduce the parameters when I call Transpose or any other function...





This example might be nice but for industrial scaled problems I'd recommend TOMNET.
To set up and solve a linear problem (see http://tomopt.com/docs/tomnet_quickguide/tomnet_quickguide003.php for the full example) you need code similar to this:
' Create arrays c, b_L, b_U etc.
' ...
' Create linear constraints as a sparse matrix.
Dim Apr As Double() = New Double(nnz  1) {1, 4, 2, 1}
Dim Air As Integer() = New Integer(nnz  1) {0, 1, 0, 1}
Dim Ajc As Integer() = New Integer((N  1) + 1) {0, 2, 4}
Dim A As New Sparse(2, 2, 4, Air, Ajc, Apr)
' Create a problem, solver and result instance.
Dim Prob As LinearProblem = New LinearProblem(c, A, b_L, b_U, x_L, x_U, x_0, name, Double.NegativeInfinity, Nothing, Nothing)
Dim result As New Result
Dim solver As New SNOPT
' set some parameters
' ...
' Solve the problem
solver.Solve(Prob, result)
' Display the solution on the console.
Console.WriteLine(" * Objective: {0,10:g3}", result.f_k)
' Display more
' ...
Other problem classes TOMNET deals with include global and nonlinear problems with linear and/or nonlinear constraints. Also there are some custom classes for numerical differentiation and sparse and dense matrices.
You find the TOMNET Optimization Platform for .NET here http://tomopt.com/tomnet/ . You can get a 21 day free demo through the our webpage or by contacting me: per.stra_DELETE_ndberg@tom_DELETE_opt.co_DELETE_m
Per

Per Erik Strandberg
.NET Architect  Optimization
Tomlab Optimization Inc.
http://tomopt.com/tomnet/





All what you say may be true, but this is free code and the codeproject is not the place for ads!
Yves





I am trying to keep up with all this stuff. It is just not sinking into this this think noggin of mine.
I am looking for a way to project factors to achieve a certain rank. See the sample chart below. For each change in "T", I rank "V" (result of f1*f2*f3) in "R". I would like to compute new factors(F1,F2,F3) to produce a desired rank (say rank 2) for each occurance where "T" = 1.
T has 5 occurances
F1 has 5 occurances
F2 has 5 occurances
F3 has 3 occurances (only one is shown)
I realize that in order to statisfy the "solve for rank" issue I could potentially raise a factor or two and then lower another factor. Example, in the series (1,1,4,1) "V" has a value of 66 "R" has a rank of 5. In order to achieve rank 2 "V" would have to fall between 41 and 42. I also realize that if I alter either of the factors, I would affect change on the other "V" that depend on those factors, so bigger picture should be clear in mind.
Anyway, if you know of direction to send me on, I would be ever grateful.
thanks in advance.
sample data:
T F1 F2 F3 V R
1 1 0.85 55 47 2
1 1.1 0.85 55 51 4
1 1.25 0.85 55 58 4
1 0.95 0.85 55 44 1
1 0.86 0.85 55 40 1
1 1 0.8 55 44 2
1 1.1 0.8 55 48 2
1 1.25 0.8 55 55 3
1 0.95 0.8 55 42 1
1 0.86 0.8 55 38 1
1 1 0.91 55 50 5
1 1.1 0.91 55 55 3
1 1.25 0.91 55 63 4
1 0.95 0.91 55 48 1
1 0.86 0.91 55 43 2
1 1 1.2 55 66 5
1 1.1 1.2 55 73 5
1 1.25 1.2 55 83 1
1 0.95 1.2 55 63 3
1 0.86 1.2 55 57 4
1 1 0.98 55 54 4
1 1.1 0.98 55 59 4
1 1.25 0.98 55 67 1
1 0.95 0.98 55 51 4
1 0.86 0.98 55 46 4
2 58 5
2 35 2
2 33 1
2 91 5
2 42 2
2 54 3
2 49 3
2 51 1
2 94 4
2 50 4
2 40 3
2 58 5
2 52 2
2 74 3
2 47 3
2 42 2
2 45 3
2 88 2
2 53 1
2 37 1
2 51 3
2 61 5
2 77 3
2 66 5
2 53 5
3 52 3
3 42 3
3 63 5
3 76 2
3 62 5
3 58 5
3 54 4
3 53 2
3 80 3
3 41 2
3 35 2
3 38 1
3 59 3
3 86 4
3 40 1
3 41 1
3 33 1
3 96 4
3 70 5
3 50 3
3 46 2
3 37 1
3 94 5
3 46 1
3 35 2
4 38 1
4 51 5
4 40 2
4 78 3
4 60 4
4 55 4
4 63 5
4 60 4
4 74 2
4 51 5
4 49 4
4 57 4
4 49 1
4 97 5
4 64 5
4 43 3
4 39 2
4 93 3
4 65 4
4 62 5
4 54 5
4 39 2
4 78 4
4 49 2
4 45 3
5 53 4
5 33 1
5 56 3
5 80 4
5 52 3
5 40 1
5 33 1
5 65 5
5 96 5
5 45 3
5 30 1
5 44 2
5 69 5
5 69 2
5 49 4
5 55 4
5 60 4
5 97 5
5 56 2
5 47 2
5 38 1
5 56 3
5 76 2
5 50 3
5 31 1





Good work,
I do prefer C# though.





So do I nowadays (I started out writing C on Unix, X11 and Motif). However, on PC in those days C was a pain to create UI apps, so I learned VB 4. This library goes back to VB 6, and was ported to VB.NET. As the integration in .NET is seamless, I see no reason to convert it to C#. There are some free (online even) tools on the web which will do that for you if you wish though.






This is the example where the error occurs. This is obviously wrong since i get a negative weird value in x(1)... there is no way 900 / 1000 = 4.954182
Matrix A(,) (Single):
'
 88000000  0  1000  2000000 

 0  1000  0  0 

 100000  1000  1000  0 

 0  0  0  2000000 
'
Vector b() (Single):
'
 960000

 900 

 0 

 60000 
'
And the solution is x() (Single):
'
0.116242252
4.954182
3.0149703
0.0299801454
The weird thing is that it works perfectly in other cases.





Hello,
your message isn't very clear, but I suppose you are using Algebra.Solve to find the solution of A.x = b?
If so, note that I get different results, except for x(3). Note that the Solve method uses Singular Value decomposition which gives an exact solution if the set of equations has one, and a least squares solution when the set is overdetermined (more equations than variables). I think your set of equations is badly illconditioned, because Matlab also gives strange, albeit different, results. Indeed, it manages to give correct results for the first 3 unknowns, but fails miserably on the last. The determinant of your matrix is also very big, which may lead to important rounding errors....
Yves





Indeed, i used Algebra.Solve.
You are basically telling me that for some matrices the code you provide wont give reliable solutions?
The thing is i have no idea what matrices it will have to solve since it depends on user input.
This system takes a second to solve by hand, how hard can it be to programatically compute reliable solutions ?





Sometimes VERY!!!!
Note that the condition number of the matrix given by you is 1.4254e+005, which means your matrix may be illconditioned (nearly singular) with respect to inversion and the used precision. According to Wolfram this means that one needs at least 6 digits precision for computations, while the .NET single or float format provides 7 digits precision, only just enough. Double gives 1516 digits, so maybe you should try that.
Yves





I tried switching your code to double (it was already double in mine) and it gave the exact same results.
I was wondering why didn't your code use doubles anyway.
There's another matrix class library here at CodeProject called "GeneralMatrix" or something writen in C#. This one gives the expected results but i didn't have time to see how they compute them.





Hello,
I have done some checking out, and basically the Singular Value decomposition should not be used to solve A.x = b when A is a square matrix. I wrote (converted it actually) it to solve overdetermined sets of equations (more equations than variables), and then SVD gives a good result in the least squares senses, i.e. with minimal A.x  b
Check out
http://www.aisto.com/roeder/dotnet/" for a C# version of MAPACK.





This is the most complete of all free matrixrelated .NET classes I've seen yet.
Just looking at code, the decomposition is nice, should make inversion fast, and the NelderMead should prove very useful too.
The error trapping is missing some dimension checks, but not too hard to insert myself...
Any reason you didn't make Matrix a declarable object? would it be bad for speed?
But then again, I've been wrong before...






The SVD actually computes an inverse, because it solves A.x = y by doing x = inv(A).y. inv(A) is not actually the inverse, but the pseudoinverse, as A is not necessarily a square matrix. This pseudoinverse is the same as the inverse when the matrix A is square and not singular (rank equal to the number of rows). I did not include a separate routine for this as 90% of the time an inverse is needed to solve a set of equations. However, I know that orthognal matrices representing rotation of coordinate systems do sometimes need to be inverted explicitly, and I suggest you check out the SVD routine itself: A = U.W.Vt, with U and V orthognal and W diagonal (t is transpose). This means that inv(A) = inv(U.W.Vt) = inv(Vt).inv(W).inv(U) = V.inv(W).Ut.
So once you have U,V and W it is easy to compute inverse of A. One note: computing the inverse of W involves computing the inverse of te diagonal elements, and this is unstable when they are close to zero!!!! Set the coressponding element in inv(W) to zero (they are called singular values, hence the name). By the way, for orthogonal matrices inv(A) = At, so thats even easier...
I only use C# for messy things like unmanaged code, so sorry ...
Yves





All I know is that if you are dealing with 4x4 matrices for 3D graphics, you need an inverse function/operator.





True, as I mentioned myself in my first reply! However, in 3D graphics 4 by 4 matrices are actually a compact notation for the combination of a translation and a rotation, obtained by adding a fourth dummy coordinate:
x' a11 a12 a13 dx x a11 a12 a13 x dx
y' = a21 a22 a23 dy . y = a21 a22 a23.y + dy
z' a31 a32 a33 dz z a31 a32 a33 z dz
1  0 0 0 1  1
with the rotation represented by a orthoganal 3 by 3 matrix.
This means basically that in order to inverse this 'operator' one has to compute the inverse of a 3 by 3 orthogonal matrix (its transpose!), NOT a 4 by 4 nonorthogonal matrix!!!!
This leads to:
x a11 a21 a31 x'  dx
y = a12 a22 a32.y'  dy
z a13 a23 a33 z'  dz Ez!;)








General News Suggestion Question Bug Answer Joke Praise Rant Admin Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

