Solving Hermitian matricies in C/C++

In summary, the person is having trouble compiling code that was written in MinGW. They have tried to install and uninstall the compiler, but the errors continue to occur.
  • #1
Pozarnik
1
0
I've been struggling for awhile, I've been trying to use CLAPACK to avoid learning Fortan. I think I've just a linking problem, since I've been testing code that's supposed to work.
in the VC command prompt i type

cl dgesv.c

and I get the error
LNK2019: unresolved external symbol _dgesv_ referenced in function _main

if I try to link the library
cl dgesv.c /link clapack.lib
then i get redundancy in some of the defaults like printf (alrady defined in LIBCMT.lib)
and i also get the error.

LNK4098 default lib 'MSVCRTD' conflicts with the use of other libs

Can someone help me fix this?
Otherwise I was trying to use seldon, but there seems to be very little information on how to use it.
 
Technology news on Phys.org
  • #2
I am attempting to bolster my coding skills by working for a Professor who has a program that needs some bugs fixed and tweaks etc... In his advertisment he said he needed someone with C++ experience...

Now I have been a recreational programmer. I have learned basic and pascal as first languages and have worked a bit VBA prior to taking on C++. I am ok with object oriented stuff I felt I could work my way through anything if needed.

So I take on this gig and get the program source files and C++ Builder 2010. It seems like a very different environment from what I was accustomed too. (I used Visual C++ express) To test it out I did a quick hello world as a console app. What I typed was about 3 lines, what compiled was like 5000!. This RAD does a lot of stuff behind the scenese i guess. The program has whole bunch of libraries i never seen before. I am not sure how to naiviage them and see what I really need. I felt with the MS stuff (VBA with MS office and it was a zillion times simpler to manipulate the ojbects). Now the stuff is like greek.


So I am lost and up the creek with a broken paddle. I want to grow and tackle this task but its much harder than I anticipated. I am relearning C++ stuff in regards to classes and libraries but I feel even this will not get me to the point to handle this RAD enviroment.

What can one read to get to this final level of programming and proficency.

Any help would be much appreciated.
 
  • #3
I am having trouble with calculating the error at the hidden layer in a back propagation network.

I have calculated the error at the output layer successfully (and verified against a working network) with the following:

Code:
for (int k=0;k<(layers[1]->n_neurons);k++) {
    //error = (desired - output) * f'(output)
    layers[1]->errors[k] = (desired[k] - layers[1]->outputs[k]) * (1 - (layers[1]->outputs[k] * layers[1]->outputs[k]));
}

Now with the information I've been given, the following (calculation of hidden layer errors) should be correct... could anyone shed some light on what I'm doing wrong?

Code:
for (int i=0;i<(layers[0]->n_neurons);i++) {
    //error[i] = f'(output[i]) * SUMMATION(outlayer_error[k] * outlayer_weights[k][i])
    sum = 0;
    for (int k=0;k<(layers[0+1]->n_neurons);k++) {
        sum += layers[0+1]->errors[k] * layers[0+1]->neurons[k]->weights[i];
    }
    layers[0]->errors[i] = (1 - (layers[0]->outputs[i] * layers[0]->outputs[i])) * sum;
}

Contextual information:

Code:
double *errors;
errors = new double[n_neurons];

Layer[0] is the hidden layer. Layer[1] is the output layer.

outputs[] is the results from the forward pass for each layer.

n_neurons is the number of neurons relative to that layer.

This is so far just the calculation of the errors. The activation function is tanh. I have a working ANN program (closed source) that I am comparing my results with, and how I am able to verify parts of the program. Including the correct output layer error calculations. They are also matching the information I was given.

I've spent about 6hours working on this so far, and I'm at the point of going crazy. So any help is really really appreciated.

Any help on adjusting the weights is also welcome, but priority is the error calculation.
 
  • #4
Hello everyone, :smile:

Yesterday I downloaded MinGW compiler only to see how a standalone compiler looks. When it finished installing after many minutes I uninstalled it because I could not even understand how to open it!:mad:

I use Dev-C++. I also have CodeBlocks installed but don't want to use it. I like the Dev. But now the problem is whenever I try to compile any code it gives the below given errors. I don't know the reason because it was only MinGW which I installed and uninstalled yesterday. Nothing else. Now I have uninstalled and installed Dev twice but still the same errors. The code and portable Dev on my flash drive works fine on my friend's computer. But on my PC even the portable version gives the same errors. Help me out please. Much grateful for any help I can get.


Errors:
[Linker error] undefined reference to `__dyn_tls_init_callback'
[Linker error] undefined reference to `__cpu_features_init'
ld returned 1 exit status

Cheers
 
  • #5


I understand your frustration with trying to solve Hermitian matrices in C/C++. It can be challenging to navigate through different libraries and linking errors. However, I would recommend taking a step back and evaluating your approach to solving this problem.

Firstly, it is important to understand the basics of Fortran, as it is the primary language used in CLAPACK. This will help you better understand and utilize the library.

If you are set on avoiding learning Fortran, there are other options for solving Hermitian matrices in C/C++. For example, the Eigen library has a built-in function for solving Hermitian matrices (Eigen::SelfAdjointEigenSolver). This may be a simpler solution for you without having to deal with linking issues.

Alternatively, you can try using a higher-level language like Python with libraries such as NumPy and SciPy, which have efficient functions for solving Hermitian matrices.

In terms of your specific linking errors, it would be best to consult with experts in C/C++ and CLAPACK for a more tailored solution. They would be able to guide you through the proper linking process and troubleshoot any errors that may arise.

In summary, while it can be frustrating to encounter linking errors, it is important to approach problem-solving in a methodical and informed manner. This may involve learning new languages or utilizing different libraries, but ultimately it will lead to a more efficient and accurate solution.
 

Related to Solving Hermitian matricies in C/C++

1. What is a Hermitian matrix?

A Hermitian matrix is a square matrix that is equal to its own conjugate transpose. In other words, it is equal to its own transpose with all of its elements reflected over the main diagonal and all complex numbers replaced by their complex conjugates.

2. How do I solve a Hermitian matrix in C/C++?

There are a few ways to solve a Hermitian matrix in C/C++. One approach is to use the Cholesky decomposition method, which decomposes the matrix into a lower triangular matrix and its conjugate transpose. You can also use libraries such as LAPACK or Eigen that have built-in functions for solving Hermitian matrices.

3. What is the difference between solving a Hermitian matrix and a regular matrix in C/C++?

The main difference is that a Hermitian matrix has complex elements, while a regular matrix has only real elements. This means that when solving a Hermitian matrix, you need to take into account the complex numbers and their conjugates. Additionally, the algorithms used for solving Hermitian matrices may differ from those used for regular matrices.

4. Can I use C/C++ to solve large Hermitian matrices efficiently?

Yes, C/C++ can be used to efficiently solve large Hermitian matrices. However, it is important to choose an appropriate algorithm and optimize your code for performance. Additionally, using parallel computing techniques can also help improve efficiency when solving large matrices.

5. Are there any common errors or pitfalls when solving Hermitian matrices in C/C++?

One common error is forgetting to take into account the complex conjugates when performing operations on the matrix. This can lead to incorrect results. It is also important to ensure that the matrix is indeed Hermitian before attempting to solve it, as non-Hermitian matrices may not have a valid solution. Finally, make sure to check for and handle any potential numerical instabilities that may arise during the solving process.

Similar threads

  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
Replies
5
Views
10K
  • Computing and Technology
Replies
11
Views
433
  • Programming and Computer Science
Replies
2
Views
2K
  • Precalculus Mathematics Homework Help
Replies
4
Views
677
  • Programming and Computer Science
Replies
4
Views
2K
  • Programming and Computer Science
Replies
4
Views
3K
  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
14
Views
7K
  • Quantum Physics
Replies
20
Views
3K
Back
Top