Can someone help me troubleshoot my Gaussian Elimination code for scaling?

  • Thread starter jinro
  • Start date
In summary, the conversation is about a problem the person is having with scaling in Gaussian elimination. They are using the code A4[a][c] = A[a][c]/t and when they print A4, it shows the correct element divided by t. However, when they try to assign A[a][c] to A4[a][c], the output becomes A[a][c]/t^2. They tried to create a new matrix A3 and assign it to A4, which worked correctly. The person is asking for help with their code.
  • #1
jinro
4
0
hi

i have this problem

this is part of my code, where i am scaling in guassian elimination

A4[a][c] = A[a][c]/t;

when i put printf A4 at the bottom, it shows the right element divided by t

when i put
A[a][c] = A4[a][c];

my output for my input when i scale becomes A[a][c]/t^2. i try to make another matrix A3, and used A3 = A4, it showed the right answer, but i can't make it work for A!
 
Technology news on Phys.org
  • #2
Show us your code. I can't figure out what's going on from your description.
 

What could be causing my C code to crash?

There are several potential causes for a C code to crash, including memory leaks, null pointers, and buffer overflows. It is important to carefully analyze your code and use debugging tools to pinpoint the exact issue.

Why is my C program not producing the expected output?

There could be a number of reasons for this, such as logical errors in the code, incorrect data types, or incorrect use of control structures. It is important to thoroughly test and troubleshoot your code to identify and fix any issues.

How do I fix a segmentation fault in my C program?

A segmentation fault is often caused by attempting to access memory that is not allocated or is out of bounds. Using a debugger can help identify the specific line of code causing the issue. Additionally, carefully managing memory allocation and addressing potential null pointers can prevent segmentation faults.

What are common mistakes to avoid when writing C code?

Some common mistakes in C programming include forgetting to properly allocate and free memory, not checking for null pointers, and using uninitialized variables. It is also important to carefully manage data types and ensure proper memory usage to avoid errors.

How can I optimize my C code for better performance?

To optimize your C code, you can use techniques such as reducing the use of global variables, avoiding unnecessary function calls, and using efficient data structures and algorithms. Additionally, profiling tools can help identify areas of your code that can be optimized for better performance.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
7
Views
895
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
4
Views
740
  • Introductory Physics Homework Help
Replies
11
Views
772
  • Programming and Computer Science
Replies
1
Views
952
  • Programming and Computer Science
Replies
4
Views
359
  • Programming and Computer Science
Replies
4
Views
2K
Replies
10
Views
1K
  • Programming and Computer Science
Replies
4
Views
631
  • Programming and Computer Science
Replies
31
Views
2K
Back
Top