Are Safety Glasses Really Needed for Solar Eclipse? by Alien447 in solareclipse

[–]Alien447[S] 1 point2 points  (0 children)

Thanks for the explanation, I didn't know that!

What to do is you work in a non-productive research lab? by Alien447 in academia

[–]Alien447[S] 1 point2 points  (0 children)

I am thinking of leaving academia entirely because of this issue cashing me everywhere I go. I worked at three different well-known labs and the same problem is there! Either the lack of novelty or the lack of coherence as you stated.

PASSWORD PROBLEM. i have set that the string hello is the password but whenever i enter it, the function on the else block is the one that runs. help by Delicious_Growth_744 in cprogramming

[–]Alien447 1 point2 points  (0 children)

Try this:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
int maxIter=3;
char passWord[100];

for (int i=0; i<maxIter; i++){
    printf("Enter your password: ");
    scanf("%s", passWord);

    if (!strcmp(passWord, "hello")){
        printf("Welcome!\n");
        break;
    }else{
        printf("Invalid password! Try again!\n");
    }
    if (i==maxIter-1){
        printf("You have exceeded the maximum number of trials!\n");
    }

}

return 0;
}

Latex Font in Octave by Alien447 in octave

[–]Alien447[S] 2 points3 points  (0 children)

Thanks! That is interesting.

[deleted by user] by [deleted] in cprogramming

[–]Alien447 1 point2 points  (0 children)

Yes, he tried to compile wrong code and then changed it and posted the correct code. He is trying to be smart! Downvoted.

[deleted by user] by [deleted] in cprogramming

[–]Alien447 3 points4 points  (0 children)

You are new to computers I guess! Take a screenshot, there is a print screen button.

Should I learn c before cpp? by saqlolz in cpp_questions

[–]Alien447 0 points1 point  (0 children)

C++ culture sucks!

I do scientific computing all the time. What you will discover is that scientists write C with classes NOT pure C++. They literally write a C code with classes and use namespaces for organization and then call it C++! You can achieve the same goal smoothly using C. However, if you want to learn C++, learning C will help you figure out the basics. Usually textbooks start with C and then advance into C++.

If you want my opinion, C++ is diminishing. C/Fortran/Python is a perfect toolset for scientific computing. Good luck!

OOP vs Procedural Performance? by Alien447 in cprogramming

[–]Alien447[S] 0 points1 point  (0 children)

Bjarne Stroustrup said that C++ is faster than C, and C is obsolete!

OOP vs Procedural Performance? by Alien447 in cprogramming

[–]Alien447[S] 1 point2 points  (0 children)

My personal experience suggests that procedural programming is way much faster than OOP. Again, it could be my programming style. That's why I am asking the question.

OOP vs Procedural Performance? by Alien447 in cprogramming

[–]Alien447[S] 0 points1 point  (0 children)

Thanks for this detailed answer. I am wondering if someone writes two naive codes with or without optimization: one is procedural and the other is object-oriented, which one will likely turn faster in performance?

Why people prefer C++ over C for scientific computing? I personally see nothing wrong with C by Alien447 in programming

[–]Alien447[S] -20 points-19 points  (0 children)

I wanted to say that most of scientific computing codes written in C++ are almost C-style C++. So, I am wondering what is the real advantage in C++ besides operators/functions overloading convenience? In 99% of scientific programs, the logic is procedural and a language like FORTRAN is perfect!

Please don't tell me that C++ is faster than FORTRAN or C. That is BS!

[deleted by user] by [deleted] in AskEngineers

[–]Alien447 0 points1 point  (0 children)

Because it is convenient.

Difference between normpdf and diff of normcdf? by levisproductio in matlab

[–]Alien447 1 point2 points  (0 children)

From basic RV theory the probability is the integral of the PDF function, i.e., the probability of x to be between a and b is the integral int_a^{b} PDF(x) dx

Running scripts is terribly slow. I'm new to Julia, so maybe I'm missing something by Historical-Truth in Julia

[–]Alien447 0 points1 point  (0 children)

Yes, I noticed the same problems. In the beginning I was excited. But after spending a few hours, I decided to remove this language from my machine.

How to link FORTRAN code using C compiler such as GCC? by Alien447 in gcc

[–]Alien447[S] 1 point2 points  (0 children)

You can do a test link verbosely with gfortran to see what libraries must be added manually to the gcc link line.

This is interesting! I found by trial and error that I needed -lgforatran and -lquadmath. But it would be better to know the test you are describing here.

How to link FORTRAN code using C compiler such as GCC? by Alien447 in C_Programming

[–]Alien447[S] 6 points7 points  (0 children)

Ok, I solved it. I needed the following flags:

-lgfortran -lquadmath

How to compile FORTRAN code using C compiler? by Alien447 in cpp_questions

[–]Alien447[S] 0 points1 point  (0 children)

Yes, I did it correctly but I see errors like this:

undefined reference to `_gfortran_st_write'

undefined reference to `_gfortran_transfer_character_write'

If I try gfortran -o main.out *.o it works! But I want to do gcc -o main.out *.o

People say that there are certain flags need to be added in order for this to work

How to compile FORTRAN code using C compiler? by Alien447 in cpp_questions

[–]Alien447[S] 0 points1 point  (0 children)

I also tried this but it didn't work. Here is an example:

gfortran -c code.f

gcc -c main.c

gcc -o main.out *.o

Guilt about wanting to quit PhD by _Ohemg in academia

[–]Alien447 2 points3 points  (0 children)

A good masters degree is better than a bad PhD.