Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
cronio
Feb 15, 2002
Drifter

Boz0r posted:

Does anyone know any good methods of getting a better overview of code? Like program graphs or some stuff like it.

Run it in a debugger, put breakpoints in the places you want to learn about, and and step through. If you don't know where to put those breakpoints yet, start at main() or its equivalent.

Adbot
ADBOT LOVES YOU

Johann Gambolputty
Jul 6, 2006
I don't know much about fortran, but my professors code was written for fortran 77. I was set to get it to compile with intel visual fortran which is essentially fortan 03. Well it took a huge struggle but there were tons of things wrong with the code which surprised me that it even worked before. Now I have this huge mess of a code that now semi works under intel visual fortran. I get different results under debug mode, release mode, 32 bit mode, 64 bit mode... But, 32 bit release gives the same results as the original code. I am currently investigating into the discrepancies.

Now I am currently thinking. Should I slog through this code fixing it up trying to get it to work. Or, should I do a slash and burn approach and try to port it over to C or something. I always hear about how horrible fortran is, I wouldn't mind sticking with it if the code wasn't rickety. I don't have too much experience with C though. Anyways, thoughts? Stick with it, or try something else.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Version control the poo poo out of it, then clean it up as you like, and keep it in Fortran.

Why would you port it to C if you're not good with C?

yatagan
Aug 31, 2009

by Ozma

pokeyman posted:

Why would you port it to C if you're not good with C?

Porting code is an awesome way to help learn a language.

Johann Gambolputty
Jul 6, 2006
Yeah figured I would like to learn it. I always hear people say Fortran sucks and would like to learn C would be my main reason. But if Fortran is actually a pretty good language then I don't mind sticking with it. We plan to go to 3D soon and there are some spots where the code is slowest where multithreading should be easy to implement. I hear that multithreading isn't officially supported in Fortran 03 either. I'd have to check if Intel's compiler does.

I'll probably stick with Fortran for now, but I'll dabble with the C part of things not really putting forth all my effort to it so I can learn the language.

Edit: By version control you mean like revision control where it keeps track of all the changes I make? The discrepancies have nothing really to do with changes. Just the compiler settings, debug, release with 32 bit or 64 bit options. So i'm not really changing the code where the discrepancies are occurring.

Johann Gambolputty fucked around with this message at 20:04 on Oct 18, 2009

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

There's nothing wrong with semi-modern Fortran standards. Yes, Fortran 77 is pretty drat archaic, but if you updated the code to Fortran 90/95 standards, then you'll have far more readable and modern code without having to rewrite the entire thing from scratch.

But, I'm not convinced porting code is the best way to learn a language, especially between languages like C and Fortran. I'm envisioning a post a few months from now where he asks "my C code is so much slower wtf" and us discovering that he didn't take into account Fortran's column-major arrays vs. C's row-major arrays and ended up blowing his cache or something. In my opinion it's better to work with what you know and save the "learn a language" projects for when they're not critical to your research/job/etc.

Dijkstracula fucked around with this message at 20:45 on Oct 18, 2009

Johann Gambolputty
Jul 6, 2006
I think then I should just make use of modules and get rid of his drat implicit instantions and things like that then. Any ideas about that version control thing though? I wasn't quite sure what was meant by that.

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

Johann Gambolputty posted:

Any ideas about that version control thing though? I wasn't quite sure what was meant by that.

He meant revision control where it keeps track of all the changes you make. You should always use revision control when you are coding. It is very easy to do, and someday it will save you a ton of pain.

Johann Gambolputty
Jul 6, 2006
Sure I will do that. But I don't know how that helps with the different results using different compiler settings. But either way thanks for the help guys.

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

Johann Gambolputty posted:

Sure I will do that. But I don't know how that helps with the different results using different compiler settings. But either way thanks for the help guys.

It means you can experiment with different things trying to fix the problem, and always go back to a clean slate when something doesn't work. Otherwise you wind up with either completely breaking it and not knowing how to get it back to how it was before, or "well I changed this and this and this other thing, and something fixed it, but I don't know what".

raminasi
Jan 25, 2005

a last drink with no ice

Johann Gambolputty posted:

Sure I will do that. But I don't know how that helps with the different results using different compiler settings. But either way thanks for the help guys.
if you're using visual fortran you can version control your project/solution files as well as your code

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

GrumpyDoctor posted:

if you're using visual fortran you can version control your project/solution files as well as your code
And even if you weren't, you could version control your makefile anyway ;)

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?

Boz0r posted:

Does anyone know any good methods of getting a better overview of code? Like program graphs or some stuff like it.

Print it out on paper with a small font. Look for anything weird looking.

raminasi
Jan 25, 2005

a last drink with no ice

Dijkstracula posted:

And even if you weren't, you could version control your makefile anyway ;)
:doh:

Ari
Jun 18, 2002

Ask me about who Jewish girls should not marry!

Triple Tech posted:

Print it out on paper with a small font. Look for anything weird looking.

This works for some people and not for others. For me, it's crucial sometimes to see a code listing on paper, because that's how my head works. I therefore recommend this if you've never tried it, to see how it works for you.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Ari posted:

This works for some people and not for others. For me, it's crucial sometimes to see a code listing on paper, because that's how my head works. I therefore recommend this if you've never tried it, to see how it works for you.

I'm taking a PSP course right now and for each code review we have to print all the code.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

MEAT TREAT posted:

I'm taking a PSP course right now and for each code review we have to print all the code.

Why would learning about how to code for the Playstation Portable necessitate printouts of code?

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Avenging Dentist posted:

Why would learning about how to code for the Playstation Portable necessitate printouts of code?

PSP

Contero
Mar 28, 2004

MEAT TREAT posted:

PSP

PSP is good, but have you tried the team-oriented synergy production process management using the fred brooks extreme software-driven data requirement metric analysis documentation for mythical man usability unit coverage tests in agile object oriented model-view-controller business logic development?

I run a seminar if you're interested.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Contero posted:

PSP is good, but have you tried the team-oriented synergy production process management using the fred brooks extreme software-driven data requirement metric analysis documentation for mythical man usability unit coverage tests in agile object oriented model-view-controller business logic development?

I run a seminar if you're interested.

Sounds just like what I need to get that promotion. Do you accept blank cheques?

BizarroAzrael
Apr 6, 2006

"That must weigh heavily on your soul. Let me purge it for you."
Trying to make a batch file that will read a .txt file, which contains a list of file pathnames, and rename (technically move, as you shall see) each listed file. Each line in the .txt starts with 20 characters that need to be removed:

code:
FOR /f "tokens=* delims= " %%a IN (C:\Test\movethese.txt) DO (
	SET MOVEFILE=%%a
	SET MOVEFILE=%MOVEFILE:~-20%
	MOVE %MOVEFILE% %MOVEFILE%_backup
)
I've returned local variables from inside FOR loops before, but manipulating one inside one seems to be limited to the SET command, is this right? MOVEFILE's value is always ~-20 when I run that. Am I going to have to bodge a loop with GOTOs?

BizarroAzrael fucked around with this message at 17:07 on Oct 20, 2009

Jethro
Jun 1, 2000

I was raised on the dairy, Bitch!

BizarroAzrael posted:

Trying to make a batch file that will read a .txt file, which contains a list of file pathnames, and rename (technically move, as you shall see) each listed file. Each line in the .txt starts with 20 characters that need to be removed:

code:
FOR /f "tokens=* delims= " %%a IN (C:\Test\movethese.txt) DO (
	SET MOVEFILE=%%a
	SET MOVEFILE=%MOVEFILE:~-20%
	MOVE %MOVEFILE% %MOVEFILE%_backup
)
I've returned local variables from inside FOR loops before, but manipulating one inside one seems to be limited to the SET command, is this right? MOVEFILE's value is always ~-20 when I run that. Am I going to have to bodge a loop with GOTOs?

http://www.robvanderwoude.com/variableexpansion.php

octobernight
Nov 25, 2004
High Priest of the Christian-Atheist Church
I have been trying to figure out how create a regexp over Alphabet={a,b,c} such that no symbol appears consecutively. I've been having problems figuring this out. I can easily draw the FSM that accepts the correct strings, and regexp and FSM are equivalent. Is there a simple way to translate a FSM to a regexp so I can solve this?

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

octobernight posted:

I have been trying to figure out how create a regexp over Alphabet={a,b,c} such that no symbol appears consecutively. I've been having problems figuring this out. I can easily draw the FSM that accepts the correct strings, and regexp and FSM are equivalent. Is there a simple way to translate a FSM to a regexp so I can solve this?

Are you talking about regexes in the formal sense or PCREs? Because the latter is trivial.

MagneticWombats
Aug 19, 2004
JUMP!

octobernight posted:

I have been trying to figure out how create a regexp over Alphabet={a,b,c} such that no symbol appears consecutively. I've been having problems figuring this out. I can easily draw the FSM that accepts the correct strings, and regexp and FSM are equivalent. Is there a simple way to translate a FSM to a regexp so I can solve this?

Reduce the transitions into regular expressions until you're left with only one to each end node. Here's one example. You should be able to figure out the rest. Also, http://lara.epfl.ch/dokuwiki/equivalence_of_finite_state_machine_and_regular_expression_languages

Only registered members can see post attachments!

MagneticWombats fucked around with this message at 01:38 on Oct 21, 2009

Contero
Mar 28, 2004

MagneticWombats posted:

Reduce the transitions into regular expressions until you're left with only one to each end node. Here's one example. You should be able to figure out the rest. Also, http://lara.epfl.ch/dokuwiki/equivalence_of_finite_state_machine_and_regular_expression_languages



Pretty sure I got this right:

((a|ca)|((b|cb)(cb)*(a|ca)))(ca|((b|cb)(cb)*(a|ca)))*|((b|ab)|((c|ac)(ac)*(b|ab)))(ab|((c|ac)(ac)*(b|ab)))*|((c|bc)|((a|ba)(ba)*(c|bc)))(bc|((a|ba)(ba)*(c|bc)))*

MagneticWombats
Aug 19, 2004
JUMP!

Contero posted:

Pretty sure I got this right:

((a|ca)|((b|cb)(cb)*(a|ca)))(ca|((b|cb)(cb)*(a|ca)))*|((b|ab)|((c|ac)(ac)*(b|ab)))(ab|((c|ac)(ac)*(b|ab)))*|((c|bc)|((a|ba)(ba)*(c|bc)))(bc|((a|ba)(ba)*(c|bc)))*

Remember you can factor things out and strike multiples out.

EDIT: If I'm being trolled he did ask for FSM->Regex. I never said it'd be pretty/the best answer.
EDIT: Oh I get it ;)

MagneticWombats fucked around with this message at 05:30 on Oct 21, 2009

octobernight
Nov 25, 2004
High Priest of the Christian-Atheist Church

MagneticWombats posted:

Reduce the transitions into regular expressions until you're left with only one to each end node. Here's one example. You should be able to figure out the rest. Also, http://lara.epfl.ch/dokuwiki/equivalence_of_finite_state_machine_and_regular_expression_languages



Yeah, I looked at that and it makes sense, but the problem is the FSM is extremely complicated.

The FSM has 4 states, all accepting.

Start -> 0 on 0, -> 1 on 1, -> 2 on 2
0 -> 1 on 1, -> 2 on 2
1 -> 0 on 0, -> 2 on 2
2 -> 1 on 1, -> 0 on 0

I'll try following the tutorial, but the elimination step is confusing with this FSM.

Contero posted:

((a|ca)|((b|cb)(cb)*(a|ca)))(ca|((b|cb)(cb)*(a|ca)))*|((b|ab)|((c|ac)(ac)*(b|ab)))(ab|((c|ac)(ac)*(b|ab)))*|((c|bc)|((a|ba)(ba)*(c|bc)))(bc|((a|ba)(ba)*(c|bc)))*

Thank you! Did you come up with this from a FSM, or did you build it by hand, or was there an algorithm you were following?

Contero
Mar 28, 2004

octobernight posted:

Thank you! Did you come up with this from a FSM, or did you build it by hand, or was there an algorithm you were following?

I made the FSM and started knocking out nodes. When you have a FSM with multiple end states, you need to do the reduction considering only one end state at a time, then 'or' the results of each reduction together. Since the state machine would have been the same if I swapped a with b with c in the beginning, I just did this once and rotated a, b and c in the final regex then or'ed all three together.


Click here for the full 518x800 image.


MagneticWombats posted:

Remember you can factor things out and strike multiples out.

EDIT: If I'm being trolled he did ask for FSM->Regex. I never said it'd be pretty/the best answer.
EDIT: Oh I get it

I have no idea what you're talking about. If you can simplify that regex I'd be interested in seeing the result.

MagneticWombats
Aug 19, 2004
JUMP!

Contero posted:

I made the FSM and started knocking out nodes. When you have a FSM with multiple end states, you need to do the reduction considering only one end state at a time, then 'or' the results of each reduction together. Since the state machine would have been the same if I swapped a with b with c in the beginning, I just did this once and rotated a, b and c in the final regex then or'ed all three together.


Click here for the full 518x800 image.



I have no idea what you're talking about. If you can simplify that regex I'd be interested in seeing the result.

Did you run the final regex through a regex tester?

octobernight
Nov 25, 2004
High Priest of the Christian-Atheist Church

MagneticWombats posted:

Did you run the final regex through a regex tester?

Yeah, I tested this with a regex tester and it worked. I'll look closer at Contero's method. Thanks for everyone's help!

EDIT:
I understand the method! Thank you so much for the diagram, that makes a lot of sense of how to merge states.

octobernight fucked around with this message at 06:34 on Oct 21, 2009

MagneticWombats
Aug 19, 2004
JUMP!

octobernight posted:

Yeah, I tested this with a regex tester and it worked. I'll look closer at Contero's method. Thanks for everyone's help!

Try "bab". It's the correct way of doing it but I thought I was being trolled because he answered with the final answer to something that was obviously a homework question.

EDIT: bab seems to work if I cut out the other three cases (probably because it's not matching the whole text). So I guess it's correct, but I just suspected that it was wrong because why else would you post a solution.

MagneticWombats fucked around with this message at 06:36 on Oct 21, 2009

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

Contero posted:

If you can simplify that regex I'd be interested in seeing the result.

There's already been a shorter version using backreferences. If you can't use those, but you can use zero-width lookaheads, you can use /^(a(?=b|c|$)|b(?=a|c|$)|c(?=a|b|$))*$/ which is equivalent to a trivial single-node finite state machine which transitions based on the next two characters instead of the next one character, but still advances one character at a time.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

ShoulderDaemon posted:

There's already been a shorter version using backreferences. If you can't use those, but you can use zero-width lookaheads, you can use /^(a(?=b|c|$)|b(?=a|c|$)|c(?=a|b|$))*$/ which is equivalent to a trivial single-node finite state machine which transitions based on the next two characters instead of the next one character, but still advances one character at a time.

I'm pretty sure he means regular expressions from formal language theory (i.e. you have concatenation, alternation, and the Kleene star). I just gave the PCRE answer because I didn't feel like dealing with formal language stuff, especially not for a homework problem (that's not mine).

octobernight
Nov 25, 2004
High Priest of the Christian-Atheist Church

MagneticWombats posted:

Try "bab". It's the correct way of doing it but I thought I was being trolled because he answered with the final answer to something that was obviously a homework question.

EDIT: bab seems to work if I cut out the other three cases. So I guess it's correct, but I just suspected that it was wrong because why else would you post a solution.

Well, if it makes you feel any better, it's not a homework problem, and this isn't for anything I'm turning in. The problem was build a FSM for the language. However, someone asked me how to translate it into regexp, since all the examples in the book are extremely simple (one accepting state).

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

Avenging Dentist posted:

I'm pretty sure he means regular expressions from formal language theory (i.e. you have concatenation, alternation, and the Kleene star). I just gave the PCRE answer because I didn't feel like dealing with formal language stuff, especially not for a homework problem (that's not mine).

Well, it's worth noting that for all finite n, you can easily transform n-lookahead FSMs into 0-lookahead FSMs because you can treat them as 0-lookahead FSMs on a different alphabet (namely, an alphabet of tuples) and because the n is fixed, you can transform the original string into a string in the tuple alphabet with another FSM, whereas the backreference method isn't in general realizable as a FSM. So from a purely theory perspective, the lookahead form is slightly preferable. In practice, it also tends to have marginally better performance, but eh.

The lookahead alphabet is also nice because if used to answer a homework question, it's more likely to make the professor call out the student to explain his answer in person, so if they didn't actually understand the material they're more likely to get caught.

RussianManiac
Dec 27, 2005

by Ozmaugh
What is a lookahead? Lambda transition in NFA?

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

RussianManiac posted:

What is a lookahead? Lambda transition in NFA?

http://www.regular-expressions.info/lookaround.html

yatagan
Aug 31, 2009

by Ozma
How the hell is a Tomcat 4.0.4 instance mounted in Apache via JkMount digesting realm passwords when it's being told to use BASIC authentication in web.xml and no digest attribute is being set in the realm config in server.xml?

On a related note, what kind of hash/digest function gives fixed length strings regardless of input using what looks like extended ASCII (e.g. `LAK78\vd.2ff)?

Edit:
I figured part of it out, "plaintext" actually means base64 encoded for tomcat. The base64 values however, are complete gibberish when I try to decode them.

yatagan fucked around with this message at 12:04 on Oct 21, 2009

Adbot
ADBOT LOVES YOU

SuperCaptainJ
Jun 24, 2005

I have a Grails application running on tomcat that has to use an insane amount of redirects (1000+) to overcome some Grails bulk data load performance issues. Of course, after several redirects, the browser will throw a "too many redirects" error. I'm not tomcat expert - is there a way to increase Tomcat's tolerance for redirects?

Edit: Nevermind, figured out that this is a client-side limitation.

SuperCaptainJ fucked around with this message at 20:09 on Oct 22, 2009

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply