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
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

the posted:

Bleh. My professor assigned a numerical programming assignment for physics. He lets us use any language, but he decided this time to give us something that required such lengthy computation that using anything besides Fortran and C would be impossible.

Well, maybe. Is this a physics class that uses numerical computing or a numerical computing class that uses physics? Especially in the former case, the Fortran may not be using the fastest algorithm for whatever you're doing, or it might be doing something stupid to slow down a fast algorithm (eg. walking through a matrix in row-major order [this is a misnomer but you probably know what I mean], which is fast in C but slow in Fortran), or it might be using more virtual memory than you have physical memory so it's hitting swap and slowing to a crawl, or whatever.

Adbot
ADBOT LOVES YOU

raminasi
Jan 25, 2005

a last drink with no ice

the posted:

Bleh. My professor assigned a numerical programming assignment for physics. He lets us use any language, but he decided this time to give us something that required such lengthy computation that using anything besides Fortran and C would be impossible.

If I were in your shoes I'd try NumPy.

floWenoL
Oct 23, 2002

the posted:

Bleh. My professor assigned a numerical programming assignment for physics. He lets us use any language, but he decided this time to give us something that required such lengthy computation that using anything besides Fortran and C would be impossible.

Sounds like a good simulation of the real world.

the
Jul 18, 2004

by Cowcaster

Otto Skorzeny posted:

Well, maybe. Is this a physics class that uses numerical computing or a numerical computing class that uses physics? Especially in the former case, the Fortran may not be using the fastest algorithm for whatever you're doing, or it might be doing something stupid to slow down a fast algorithm (eg. walking through a matrix in row-major order [this is a misnomer but you probably know what I mean], which is fast in C but slow in Fortran), or it might be using more virtual memory than you have physical memory so it's hitting swap and slowing to a crawl, or whatever.

It's a normal Physics course (Electromagnetism to be exact) that occasionally has programming assignments (I've posted about them before in the Python thread here and Numerical/Scientific thread in SAL). It's using RK2 approximation on a giant sphere of rotating current with respect to two different differential equations. In the assignment he uses the phrase, "Write a computer code to solve the Maxwell equations for the current sphere using RK2. You will need to use a compiled language, such as fortran or C; otherwise your code will be hopelessly slow."

GrumpyDoctor posted:

If I were in your shoes I'd try NumPy.

I'm already using both numpy and scipy packages.

the fucked around with this message at 21:46 on Mar 12, 2013

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Try adding http://pypy.org/ and maybe some of it is parallelizeable?

Industrial
May 31, 2001

Everyone here wishes I would ragequit my life
Does anyone know if it is theoretically possible to make a Windows 8 touchscreen app that creates a graphic overlay that runs on top of other apps and has buttons that respond to touch without deactivating touch controls on the underlying app?

Bunny Cuddlin
Dec 12, 2004
If I wanted to write a toy operating system for a toy architecture, is Modern Operating Systems the book to buy?

ToxicFrog
Apr 26, 2008


the posted:

Bleh. My professor assigned a numerical programming assignment for physics. He lets us use any language, but he decided this time to give us something that required such lengthy computation that using anything besides Fortran and C would be impossible.

JITs are very good these days. LuaJIT, PyPy, and recent JVMs can all approach (or in some cases exceed, thanks to dynamic optimization) C performance once they warm up. There are higher startup costs, but if you're going to be running one long-running computation rather than spawning lots of short-lived processes, that isn't a problem. And even if you don't have a JIT, in many languages it's possible to write a small module in C to handle the really computation-intensive part and do everything else around it in a HLL.

If the problem is amenable to parallelization (I'm not a physics guy), some of these languages make that much easier to do than it would be in C or Fortran, too.

(and on the flip side, just using a compiled language doesn't automatically make things fast. If you choose the wrong algorithm your code will run like poo poo on any reasonably-sized input even if, on paper, it's 10x faster than the interpreted equivalent. And if you're using something like Haskell, the "wrong" algorithm will sometimes blow everything else away because the compiler can optimize away most of it, while the "right" algorithm will turn out to have horrifying space complexity and send you into swap instantly.)

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

ToxicFrog posted:

JITs are very good these days. LuaJIT, PyPy, and recent JVMs can all approach (or in some cases exceed, thanks to dynamic optimization) C performance once they warm up.

This is true mostly in contrived cases

ToxicFrog posted:

And even if you don't have a JIT, in many languages it's possible to write a small module in C to handle the really computation-intensive part and do everything else around it in a HLL.

This is more on the ball; the poster in question mentioned he had tried Numpy and Scipy, which do exactly this with existing well optimized and tested Fortran and C routines.

Nippashish
Nov 2, 2005

Let me see you dance!
Not using numpy is the wrong answer to basically every problem that involves doing numerical simulation in python. Numpy is very fast. If you compile it against Intel's MKL or ATLAS then it's even faster.

Your program can still be very slow if you do silly things like:
code:
xs = some big numpy array of length 10000
ys = np.zeros(10000)
for x in xrange(10000):
    ys[i] = some_function(x[i])
but that's the wrong way to use numpy.

If your problem really is doing lots of little, dependent calculations in a tight loop then you should write it in C or cython and call it from python. Pypy and similar are non-options because as far as I know they're not supported by numpy and as I said above using python and not using numpy is basically always the wrong answer for numerical simulations.

Deus Rex
Mar 5, 2005

the posted:

Bleh. My professor assigned a numerical programming assignment for physics. He lets us use any language, but he decided this time to give us something that required such lengthy computation that using anything besides Fortran and C would be impossible.

edit: thought i had reached the bottom of the end. just use numpy!

Peristalsis
Apr 5, 2004
Move along.

the posted:

"You will need to use a compiled language, such as fortran or C; otherwise your code will be hopelessly slow."

Here's the thing: your prof has told you that you need to use Fortran or C. If you get clever, use Python or whatever, and you can't make it work fast enough to satisfy the prof, he's going to say "this is why I told you to use a better language for this." There won't be a lot of sympathy or room for partial credit. Even if yours works faster than the other students' programs, written in C/Fortran/Assembler/whatever, he may still get pissy at you for not following his pretty clear instructions. It's also possible that he plans to follow up this assignment with another that builds on it, and that even if your Python wizardry makes this one work nicely, it will crumble under the additional strain you'll put on it later.

If you use Python/Ruby/Perl/Excel, you're basically gambling that you can show the prof he's wrong, and get points for being so industrious and free-thinking. There are lots of ways that can go wrong, many of them involving the prof not being wrong after all.

If you're really interested in seeing if you can do it, then I suggest that you work out the program in a compiled language, like he said, then re-implement it in whatever interpreted syntax you want, and do some comparisons between the approaches. THAT's how you brown-nose.

Also, is Matlab an option for you? Though it's interpreted at the command line and even when running scripts, it's designed to run pretty fast for math stuff, and I think there used to be a compiler module you could get to generate executable files from it when you need some extra speed.

Peristalsis fucked around with this message at 14:34 on Mar 13, 2013

Bunny Cuddlin
Dec 12, 2004

Peristalsis posted:

Also, is Matlab an option for you? Though it's interpreted at the command line and even when running scripts, it's designed to run pretty fast for math stuff, and I think there used to be a compiler module you could get to generate executable files from it when you need some extra speed.

Please don't do this to people.

JawnV6
Jul 4, 2004

So hot ...

Bunny Cuddlin posted:

If I wanted to write a toy operating system for a toy architecture, is Modern Operating Systems the book to buy?

My course used Operating System Concepts, which was just fine. What toy architecture?

Bunny Cuddlin
Dec 12, 2004

JawnV6 posted:

My course used Operating System Concepts, which was just fine. What toy architecture?

Right now I'm using SIC, from this book that I used in school a while ago. I think I'm going to end up designing my own toy architecture as part of this project, though, primarily because SIC is subroutine-oriented and doesn't have enough spare GP registers to make a workable stack-based system (and I'm worried the publisher will get upset if I end up writing blog posts about it or something). This just a for-fun project that I don't have any timeline for completing so limiting my goals isn't really a concern.

oRenj9
Aug 3, 2004

Who loves oRenj soda?!?
College Slice

JawnV6 posted:

My course used Operating System Concepts, which was just fine. What toy architecture?

This book provides a decent overview of concepts, but implementation strategies tended to be beyond the scope of the book. Some chapter assignments were to implement the concepts of the chapter into Linux, but they rarely went into much detail about how to complete the assignment.

If you know what you're trying to do and just want an overview on the cost-benefit of different strategies, this is a great book. But if you're looking for a book that will hold your hand though each step of implementing an OS, it would be wise to look elsewhere.

actionjackson
Jan 12, 2003

How do I insert mathematical scripts (like a superscript 2 to denote a square) into jEdit? Perhaps the question is more about R, I'm trying to have an axis label that uses a superscript. This isn't making it very clear.

http://127.0.0.1:27256/library/grDevices/html/plotmath.html

actionjackson fucked around with this message at 21:16 on Mar 13, 2013

Bunny Cuddlin
Dec 12, 2004
I didn't realize Operating Systems: Design and Implementation had an edition as new as Modern OS. I think I'm going to go with that.

Edit: Now that I've decided on an OS book, any recommendations on an architecture book? I have a second edition of Computer Architecture by Hennessy and Patterson, is the current (linked) version of that text worth buying? Is there something else I should look at?

Bunny Cuddlin fucked around with this message at 22:09 on Mar 13, 2013

1337JiveTurkey
Feb 17, 2005

Bunny Cuddlin posted:

I didn't realize Operating Systems: Design and Implementation had an edition as new as Modern OS. I think I'm going to go with that.

Edit: Now that I've decided on an OS book, any recommendations on an architecture book? I have a second edition of Computer Architecture by Hennessy and Patterson, is the current (linked) version of that text worth buying? Is there something else I should look at?

Tanenbaum's architecture book is pretty good as well.

Deus Rex
Mar 5, 2005

Bunny Cuddlin posted:

I didn't realize Operating Systems: Design and Implementation had an edition as new as Modern OS. I think I'm going to go with that.

Edit: Now that I've decided on an OS book, any recommendations on an architecture book? I have a second edition of Computer Architecture by Hennessy and Patterson, is the current (linked) version of that text worth buying? Is there something else I should look at?

what the gently caress has been going on in the world of CS textbook cover art

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Delightfully insane covers is a longstanding tradition for CS textbooks.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

Deus Rex posted:

what the gently caress has been going on in the world of CS textbook cover art

Seriously- you want me to believe it's a textbook about operating systems without a single god damned dinosaur on the cover?

Stephen
Feb 6, 2004

Stoned
I'm trying to create a .htaccess RewriteRule that will match the first part of the url path up until the very first '/'.

For example:
http://www.asdf.com/test/hello/something/ would only match "test".

So far the best I can come up with is:
RewriteRule ^(.*?)/$
RewriteRule ^(.*?)$

But this will return: 'test/hello/something' and won't stop at the first '/'.

I've tried a few searches, but I can't seem to find anything that works and I feel like I'm entirely off on the whole thing. Any help would be appreciated, thanks!

Opinion Haver
Apr 9, 2007

I'm not too familiar with rewrite rules, but the $ at the end is forcing it to go all the way to the end of the string. So try just ^(.*?)/ and see if that works.

Stephen
Feb 6, 2004

Stoned

yaoi prophet posted:

I'm not too familiar with rewrite rules, but the $ at the end is forcing it to go all the way to the end of the string. So try just ^(.*?)/ and see if that works.

Holy loving poo poo I feel like an idiot. I thought the $ on the end was for keeping the matched string as a variable for the rest of the rewrite.

Thank you, good sir.

Stephen
Feb 6, 2004

Stoned

Stephen posted:

Holy loving poo poo I feel like an idiot. I thought the $ on the end was for keeping the matched string as a variable for the rest of the rewrite.

Thank you, good sir.

Ah, balls. This breaks the URLs for all of my /css, /js and /images files now, even with the RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d lines in.

Opinion Haver
Apr 9, 2007

I could probably help if you post more context for what exactly it is that you're trying to do, and what you have right now in terms of your .htaccess file.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I am wondering about good forecasting/anticipation algorithms for predicting a fairly periodic, regular event. I'm trying to react to a change every minute, with a error of potentially a few seconds. Meanwhile, I'd like to keep the system otherwise occupied, to the point it wouldn't immediately respond to the change if it happened during the unresponsive period. I figure there are some approaches of this that teach itself after a little trial and error, and end up doing something like:

time since reacting to last event + 0: Check for change. No change. Go unresponsive for 55 seconds
time since reacting to last event + 55: Check for change. No change. Go unresponsive for 3 seconds
time since reacting to last event + 58: Check for change. No change. Go unresponsive for 1 second
time since reacting to last event + 59: Check for change. No change. Go unresponsive for 0.5 seconds
time since reacting to last event + 59.5: Check for change. No change. Go unresponsive for 0.25 seconds
time since reacting to last event + 59.75: Check for change. No change. Go unresponsive for 0.25 seconds
time since reacting to last event + 60.00: Check for change. No change. Go unresponsive for 0.25 seconds
time since reacting to last event + 60.25: Check for change. No change. Go unresponsive for 0.125 seconds
... [Change occurs]
time since reacting to last event + 60.375: Check for change. Found change. React.

Honestly I could probably just hard-code that and be done with it, but thinking about it made me wonder what else just might be out there anyways.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Deus Rex posted:

what the gently caress has been going on in the world of CS textbook cover art

The second edition of Tanenbaum's OS book was pretty weird:

armorer
Aug 6, 2012

I like metal.

Carthag posted:

The second edition of Tanenbaum's OS book was pretty weird:



This is fantastic. More CS text books need this kind of absurd yet strangely accurate humor. Knowing that something like this might be lurking a few pages ahead would definitely keep me reading.

Bunny Cuddlin
Dec 12, 2004

Carthag posted:

The second edition of Tanenbaum's OS book was pretty weird:



hahaha FAT-16 and FAT-32

Catalyst-proof
May 11, 2011

better waste some time with you

armorer posted:

This is fantastic. More CS text books need this kind of absurd yet strangely accurate humor. Knowing that something like this might be lurking a few pages ahead would definitely keep me reading.

If by strangely accurate you mean 'inaccurate'. Trojan horses do not poo poo core dumps.

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

horse mans posted:

If by strangely accurate you mean 'inaccurate'. Trojan horses do not poo poo core dumps.

They do if they segfault :v:

Bunny Cuddlin
Dec 12, 2004

horse mans posted:

If by strangely accurate you mean 'inaccurate'. Trojan horses do not poo poo core dumps.

That depends on your frame of reference. In terms of cartoon depictions of circus tents as metaphors for operating system concepts go, I'd say this one is pretty accurate.

Ibsen
Jun 20, 2006
I am Not.
I have an old dbf from a Foxpro application that has a date field where the date is in the format of 2 ascii characters. I don't know but its possible other associated date information is missing from the dbf. But as an example Mû "might" represent today's date (3/14). Other examples include Mß or ;½ (might be a really old date) or MÝ

They run the gamut, not just starting with M. I don't know if the rendered dbf is ordered by date.

nielsm
Jun 1, 2009



Ibsen posted:

I have an old dbf from a Foxpro application that has a date field where the date is in the format of 2 ascii characters. I don't know but its possible other associated date information is missing from the dbf. But as an example Mû "might" represent today's date (3/14). Other examples include Mß or ;½ (might be a really old date) or MÝ

They run the gamut, not just starting with M. I don't know if the rendered dbf is ordered by date.

I'm guessing your question is "how to decode that date"?

I can think of two ways it can be encoded. Either as a set of bitfields, or as a number of days since some epoch.
A likely bitfield representation would be 5 bits for day of month, 4 bits for month and 7 bits for year. If the database uses little endian integers it probably uses DMY ordering for the bitfields, otherwise YMD if it's big endian, based on those examples you gave.

In little endian, Mû as an integer is 0xfb4d which is pretty high, in big endian it's 0x4dfb. If I treat either of those as a number of days and subtract it from 2013-03-14 I just get some random dates that don't look like they'd be chosen as the start of an epoch. (1958-07-18 and 1837-01-23 respectively.)

Although I can't make out anything sensible from looking at it as bitfields either.

Ibsen
Jun 20, 2006
I am Not.
Good information, nice shot anyways. Thanks. I'll post back here if I come up with anything else.

raminasi
Jan 25, 2005

a last drink with no ice
I'm working on a little learning project. I want to make a little photo viewer thing with metadata and that sort of thing. I'd like to store everything (the photos and the metadata) in a database, presumably with SQLite, because that's one of the things I'm trying to learn with the project. However, I'm not sure the best way to iteratively develop a database application. Obviously I'm not going to be able to completely design the final database at the very beginning, because I'm totally new to this stuff. So what's the best way to make my little app able to read the "previous version" of the database? My initial thought is "make the application flexible in reading so that it can read the 'previous version' gracefully," but maybe there's a better way. Update scripts seem like more complexity than I'd like to deal with, although maybe SQLite makes that kind of thing easy.

The project is Java (the other thing I'm trying to learn), if that matters.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Look into database migrations. They specify changes to your schema. Usually you'll record in the db which migrations you've already run against that db. When your app opens the db, apply any newer migrations to bring the db up to the latest version.

I don't know much about Java but I'm sure there's a library that's written to do exactly this.

e: Also test out performance if you're dumping like 50MB+ blobs into SQLite. It won't fall apart or anything but it might slow down.

Adbot
ADBOT LOVES YOU

Doctor w-rw-rw-
Jun 24, 2008

pokeyman posted:

Look into database migrations. They specify changes to your schema. Usually you'll record in the db which migrations you've already run against that db. When your app opens the db, apply any newer migrations to bring the db up to the latest version.

I don't know much about Java but I'm sure there's a library that's written to do exactly this.

e: Also test out performance if you're dumping like 50MB+ blobs into SQLite. It won't fall apart or anything but it might slow down.

There is: http://flywaydb.org/documentation/database/
But it doesn't support SQLite. In Java, H2 is the database-as-a-file engine that seems to be the most convenient. I've used it before and it's decent -- and it also comes with a web interface. It's a little more of a 'proper' SQL, and it does work with Flyway for migrations.

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