| New Reply |
Need help with Fortran |
Share Thread | Thread Tools |
| Mar14-12, 06:02 AM | #1 |
|
|
Need help with Fortran
Hi,
I'm trying to generate a set of random vectors with binary values. I need to generate them such that each time, one new vector gets added to the existing matrix. I have been using call random_number(ranval) for the generation, but I haven't been able to get linearly independent vectors. (I need to orthogonalize them, so the vectors have to be linearly independent) Any help would be much appreciated. Any info on random number generators would also be useful. Thanks, S. (P.S. I am currently working with Fortran77) |
| Mar14-12, 08:27 PM | #2 |
|
Mentor
|
How big are the vectors? And when you say "binary values" I'm assuming you mean the vectors consist of 0s and 1s - just checking. It might be that you can't do what you're trying to do. Let's say for the sake of simplicity that your vectors have 4 elements, such as <0, 1, 1, 1>. If you generate a vector with four values, that vector and the one you just generated might not form a linearly independent set of vectors. In any case, you'll never get more than 4 vectors for a linearly independent set (with n = 4). The same limitation exists for higher dimension vectors. If n = 25, you won't be able to get more than 25 vectors in your matrix. Maybe you know all this, but since I don't know your mathematical background, I felt I should mention it. |
| Mar14-12, 09:40 PM | #3 |
Recognitions:
|
Your question seems to be about generating Hadamard matrices, or a generalization of them. http://en.wikipedia.org/wiki/Hadamard_matrix
|
| Mar14-12, 11:14 PM | #4 |
|
|
Need help with FortranThanks for the info |
| Mar14-12, 11:23 PM | #5 |
|
|
What I'm doing at present is adding one vector at a time to my existing matrix using a random number generator (my random numbers are between 0 and 1, so I made anything lesser than 0.5 a -1, and the rest are +1's.) Should I change my random number generator, or would it be a better idea to ignore a dependent vector and generate a new vector in its place? Thanks for the reply |
| Mar15-12, 01:23 AM | #6 |
|
Mentor
|
Why do you have -1 entries in your vectors? There's nothing wrong with it, but when most people think binary, they think 0 and 1. Having a 0 instead of a -1 might make the calculations easier.
If your vectors are length 10, you should be able to come up with 10 lin. independent vectors. What I would do is generate a vector, and then figure out if that vector and the ones I already had form a linearly independent set. I don't know any good algorithms for that, but at each step (with N vectors, where 2 <= N <= 10), you need to solve N equations for N unknowns. If the only solution is c1 = c2 = ... = cN = 0, then the vectors are linearly independent. If the vector I just came up with turned out to be a linear combination of the others (hence the set of vectors is now linearly dependent) I would discard it, and try again. |
| Mar15-12, 02:21 AM | #7 |
|
|
Thanks again for your patience. (P.S. I'm still fairly new to Fortran, so am having some trouble finding my way around) |
| Mar16-12, 05:17 AM | #8 |
|
|
I figured it out. Thanks
|
| New Reply |
| Tags |
| fortran, linearly independent, random number |
| Thread Tools | |
Similar Threads for: Need help with Fortran
|
||||
| Thread | Forum | Replies | ||
| Fortran 77 help making an empty array (or blank list if they exist in fortran) | Programming & Comp Sci | 5 | ||
| FORTRAN 95: New to fortran, want to learn how to input a function | Programming & Comp Sci | 1 | ||
| MPI in Fortran | Programming & Comp Sci | 2 | ||
| Accessing Fortran Modules within a Fortran library from Fortran | Programming & Comp Sci | 0 | ||
| Fortran v.s. Visual Fortran | Programming & Comp Sci | 0 | ||