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
ToxicFrog
Apr 26, 2008


etcetera08 posted:

Yeah synirc is fine now. Everyone was getting k/b'd earlier.

It's totally not fine, a whole bunch of people just got kickbanned for idling (including me).

Adbot
ADBOT LOVES YOU

TasteMyHouse
Dec 21, 2006
yeah, I could parse the ascii in a snap. that's not what's been assigned to me though. I've been assigned specifically to read the binary format, for performance reasons apparently.

My boss is talking to someone who he thinks might be able to get me the spec. meanwhile, I'm just trying to "crack" it by comparing ascii / binary output.

etcetera08
Sep 11, 2008

ToxicFrog posted:

It's totally not fine, a whole bunch of people just got kickbanned for idling (including me).

From #cobol? That might've been by design...

Le0
Mar 18, 2009

Rotten investigator!
I've been asked in implementing a checksum algorithm based on J.G. Fletcher algorithm.
Along the algorithm there is 4 different set of data that can be tested to see if the checksum value resulting is correct or not. I've been working on this for a long time and I can't for the life of me find what is wrong with it.

I posted it on stackoverflow but some turd down voted it because he couldn't read my question.

Maybe anyone could give me an hand on this please? http://stackoverflow.com/questions/8315215/checksum-algorithm-based-on-j-g-fletcher

robostac
Sep 23, 2009
Are you sure your types are correct? - I've been able to match your output by making uint8 a signed char instead of unsigned. If I explicitly set it to be unsigned char it works fine.

edit: http://pastebin.com/qear65jS is the program I was using, with gcc version 4.6.1.

Le0
Mar 18, 2009

Rotten investigator!

robostac posted:

Are you sure your types are correct? - I've been able to match your output by making uint8 a signed char instead of unsigned. If I explicitly set it to be unsigned char it works fine.

edit: http://pastebin.com/qear65jS is the program I was using, with gcc version 4.6.1.

Thanks man, you were right someone very clever in our office defined a uint8 type as char instead of unsigned char... I feel really stupid now

Opinion Haver
Apr 9, 2007

etcetera08 posted:

From #cobol? That might've been by design...

code:
<@dittoed> .seen ToxicFrog
<skybot> dittoed: ToxicFrog was last seen 1 year, 4 months ago saying: gently caress SVN, and gently caress starcraft~
<cptmath> lmao
<-- rotor has kicked ToxicFrog ( a year and a half? gently caress you)
--> ToxicFrog (~ToxicFrog@synIRC-B1F524BD.cable.teksavvy.com) has joined #cobol
<@dittoed> autojoin
<@dittoed> lol
<nc_> There are a lot more idlers in here than normal
<cptmath> .tag ToxicFrog lurker
<skybot> cptmath: tag added
-- Mode #cobol [+b *!*ToxicFrog@synIRC-B1F524BD.cable.teksavvy.com] by ChanServ
<-- ChanServ has kicked ToxicFrog (Requested (rotor))
Yep.

TasteMyHouse
Dec 21, 2006

Le0 posted:

Thanks man, you were right someone very clever in our office defined a uint8 type as char instead of unsigned char... I feel really stupid now

you should use the standard integer typedefs in stdint.h for this reason.

maskenfreiheit
Dec 30, 2004
.

maskenfreiheit fucked around with this message at 21:27 on Apr 28, 2019

Le0
Mar 18, 2009

Rotten investigator!

TasteMyHouse posted:

you should use the standard integer typedefs in stdint.h for this reason.

I'm not allowed to use all the standard libraries because this is a Space project and the regulation are harsh

nielsm
Jun 1, 2009



Le0 posted:

I'm not allowed to use all the standard libraries because this is a Space project and the regulation are harsh

stdint.h does not actually define any functions or such. It is supplied by the compiler as a way to let your code specify integers of specific bit-widths and signedness without you having to make assumptions or guesses. It literally only contains a series of typedefs and some #defines for the numerical limits of the defined types.
If there are regulations that really prevent you from using that kind of declarations, those regulations need a thorough review.

Johnny Cache Hit
Oct 17, 2011

Le0 posted:

I'm not allowed to use all the standard libraries because this is a Space project and the regulation are harsh

So it's better to throw the well understood standard data types header in favor of letting programmers roll their own? :psyduck:

I feel another Mars Climate Orbiter coming up soon.

Seriously though go reread the project restrictions because I really hope you're interpreting them wrong.

Le0
Mar 18, 2009

Rotten investigator!
Well I'm not personally in favor of this regulation because in wanting to be more secure it actually isn't really but we have no choice, we're working with the ESA European Space Agency and they have very unforgiving standards. I should probably check it again to see really if we can't use this.

For example, RTEMS, open real time OS we're using (we're doing embedded btw), which has been used in a lot of the space programs also redefines all the common types in its own header.

Anyway with the loving crazy amount of software testing this piece of code will go thru, I really doubt that the major issue will be type definition ;)

EDIT: Now that you're speaking about it, I should probably check if there is a header file defining type for the processor we're using (LEON2)

rolleyes
Nov 16, 2006

Sometimes you have to roll the hard... two?
There are some problems which, when you take a step back, are nice to have. Not that yours isn't an annoying one but drat, you're working on actual space tech! I'm envious.

maskenfreiheit
Dec 30, 2004
.

maskenfreiheit fucked around with this message at 21:28 on Apr 28, 2019

Mr. Crow
May 22, 2008

Snap City mayor for life
Is there a tool to grab a schema of a Database, preferably one where I can check what I do and do not want included in it?

To clarify, something that can get me something closeish to this, just in plain text or whatever


pre:
TABLE
<Table Descripion>
Column Name	Data Type	Encrypted	Allow Nulls	Description
uniqueid	tinyint		No		No		<Description>
Description	nvarchar(100)	No		Yes		<Description>

Mr. Crow fucked around with this message at 23:35 on Nov 30, 2011

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


GregNorc posted:

Is there a good R tutorial for people who just need to get stuff done?

Venables & Smith is the standard overview of the basic features of the language.

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

GregNorc posted:

So I''m trying to use subset() in R to remove inelligible participants from some study data.

subset(lShare, yob >= 1994 & shares_yn=="Yes" & time_in_country >= 5)

Which returns nothing. I think the issue is I need to specify a SELECT statement, but I'm unsure how to specify I want to return all columns (I tried * and ALL to no avail...)

From what you've posted, your subset should already return all columns. For example, this works for me:

code:
passwd = read.csv( "/etc/passwd", sep=":", header=FALSE, col.names=c("username","password","uid","gid","gecos","home","shell") )
subset(passwd, uid >= 1000 & username != "nobody")
There's probably some problem in how you're getting your data. It would be helpful if you could post enough data and code for other people to replicate your error.

Neslepaks
Sep 3, 2003

I have an algorithm question of sorts.

I have a list of strings that I wish to combine, first in pairs, then when that's exhausted, triplets, and so on. The combinations will be used as keys in a dictionary, let's say.

Now, I would like to avoid storing state about what I've last picked, so I want to find the next free combination by a binary search, probing the dictionary. That obviously requires some sort of deterministic order.

So far all is well. The problem is I'd rather have the results come out in a not obviously linear order. That doesn't mean it has to be truly random, but I don't want fifty combinations starting with "string one" before moving on to fifty combinations starting with "string two", etc.

I've been trying to figure out a way to skip along the list using some hard-coded magic numbers or something, but that doesn't quite seem to work.

Can anyone see a solution?

Thanks!

maskenfreiheit
Dec 30, 2004
.

maskenfreiheit fucked around with this message at 21:28 on Apr 28, 2019

TasteMyHouse
Dec 21, 2006

Neslepaks posted:

I have an algorithm question of sorts.

I have a list of strings that I wish to combine, first in pairs, then when that's exhausted, triplets, and so on. The combinations will be used as keys in a dictionary, let's say.

Now, I would like to avoid storing state about what I've last picked, so I want to find the next free combination by a binary search, probing the dictionary. That obviously requires some sort of deterministic order.

So far all is well. The problem is I'd rather have the results come out in a not obviously linear order. That doesn't mean it has to be truly random, but I don't want fifty combinations starting with "string one" before moving on to fifty combinations starting with "string two", etc.

I've been trying to figure out a way to skip along the list using some hard-coded magic numbers or something, but that doesn't quite seem to work.

Can anyone see a solution?

Thanks!

Apply a Fisher-Yates shuffle to your results list.

Johnny Cache Hit
Oct 17, 2011
e: f; b

Neslepaks posted:

I have an algorithm question of sorts.

I have a list of strings that I wish to combine, first in pairs, then when that's exhausted, triplets, and so on. The combinations will be used as keys in a dictionary, let's say.

Now, I would like to avoid storing state about what I've last picked, so I want to find the next free combination by a binary search, probing the dictionary. That obviously requires some sort of deterministic order.

So far all is well. The problem is I'd rather have the results come out in a not obviously linear order. That doesn't mean it has to be truly random, but I don't want fifty combinations starting with "string one" before moving on to fifty combinations starting with "string two", etc.

I've been trying to figure out a way to skip along the list using some hard-coded magic numbers or something, but that doesn't quite seem to work.

Can anyone see a solution?

Thanks!

I'm a firm believer that the simple solution is the best... so why don't you just build your list then shuffle?

Neslepaks
Sep 3, 2003

Kim Jong III posted:

e: f; b


I'm a firm believer that the simple solution is the best... so why don't you just build your list then shuffle?

No, see, if I build the list and shuffle it before starting to pick, I'd have to store/persist the shuffled lists and I wanted to avoid that. But yeah, maybe it'll have to be that way.

Johnny Cache Hit
Oct 17, 2011

Neslepaks posted:

No, see, if I build the list and shuffle it before starting to pick, I'd have to store/persist the shuffled lists and I wanted to avoid that. But yeah, maybe it'll have to be that way.

Huhwhat?

You've got a dictionary with n entries. You want all permutations of those n entries (unless you don't care about order, in which case you want all combinations).

In your original post you claim to have the deterministic process to generate the output, but you just want to have it unordered. So build your output, and then shuffle the output.

Am I misreading your original post -- do you or do you not have the process to go from {'hello', 'there', 'world'} to {'hello', 'hellothere', 'hellothereworld', 'there', ...}?

qntm
Jun 17, 2009
Building the list and then shuffling it is trivial, but if the dictionary has more than a dozen words then that list is going to be gigantic.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

Kim Jong III posted:

Huhwhat?

You've got a dictionary with n entries. You want all permutations of those n entries (unless you don't care about order, in which case you want all combinations).

In your original post you claim to have the deterministic process to generate the output, but you just want to have it unordered. So build your output, and then shuffle the output.

Am I misreading your original post -- do you or do you not have the process to go from {'hello', 'there', 'world'} to {'hello', 'hellothere', 'hellothereworld', 'there', ...}?
It really isn't that complicated, the dude doesn't want to use obscene amounts of memory in his algorithm. Permutations are O(n!), are you really suggesting that he stores an entire N! sized list in memory?

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Neslepaks posted:

No, see, if I build the list and shuffle it before starting to pick, I'd have to store/persist the shuffled lists and I wanted to avoid that. But yeah, maybe it'll have to be that way.
I guess you could come up with a numbering scheme for the combinations so that you can just store a shuffled list of ints rather than a shuffled list of strings, or use a PRNG with a long enough period to avoid duplicates.

Johnny Cache Hit
Oct 17, 2011

qntm posted:

Building the list and then shuffling it is trivial, but if the dictionary has more than a dozen words then that list is going to be gigantic.

With a dictionary of length n, it will have n! entries.

If we assume that each permutation takes up just 1 byte:

10 dictionary entries: 3 megabytes
11 dictionary entries: 39 megabytes
13 dictionary entries: 6 gigabytes

Unfortunately if you actually need all permutations, you aren't going to escape this.

One idea -- if you have a very large dictionary and need to run some process on a large number of permutations, you could always generate each permutation on the fly by first shuffling the dictionary and flipping a coin for each entry, taking only heads for the permutation.

If your dictionary was big enough, you probably wouldn't even need to worry about checking for repetition because the number of permutations would be obscenely large.

All this leads me to

Orzo posted:

It really isn't that complicated, the dude doesn't want to use obscene amounts of memory in his algorithm. Permutations are O(n!), are you really suggesting that he stores an entire N! sized list in memory?

If Neslepaks needs an permutation of a dictionary, which is exactly what was asked for in the original post, what the hell else can be done other than generate a permutation of a dictionary?

Neslepaks: what are you trying to accomplish?

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
Yeah I guess you're right, if he's using the results as keys to a dictionary he'll need that much memory anyway. Build and shuffle does seem the simplest here.

JawnV6
Jul 4, 2004

So hot ...

TasteMyHouse posted:

yeah, I could parse the ascii in a snap. that's not what's been assigned to me though. I've been assigned specifically to read the binary format, for performance reasons apparently.

My boss is talking to someone who he thinks might be able to get me the spec. meanwhile, I'm just trying to "crack" it by comparing ascii / binary output.

So how many weeks of your time are you planning on burning before even checking the performance of regexes over the ASCII?

Neslepaks, I was working on something similar recently for a card game. I had (28 choose 7) = 1,184,040 possible hands and wanted to analyze them. I wanted a way to easily associate a particular hand with a simple integer. So I spent a little time and wrote a brute-force algorithm that would step through every possibility. I spent a few days thinking trying to figure out complicated ways to slice up the million possibilities so that I could make going from a number to a hand really really fast. The best idea I had was something like a jump table: if you just check index 0 you can slice the million up into chunk of at most 296,000, then checking the other indexes for alignment (i.e. entry 1 is the next card after entry 0) slices it up even further. If you're dealing with a huge number of entries that might help.

Then I went and actually checked performance. Turns out the brute force takes under 1/5th of a second if it's just stepping through the indexes, not printing out hands, etc.. So the 'quick' way of doing it is "run the brute force n times then stop". And all that thinking was just wasted time.

Neslepaks
Sep 3, 2003

Actually the combinations will be persisted in a key-value store or something like that. My idea was to be able to restart the application and have it pick up where it left off, without it having to store any state. It's no problem to achieve this as long as I accept that the picks come out in a linear fashion, but I was hoping there was some clever trick to introduce the illusion of randomness to this scheme.

Thanks for all the replies so far. :)

TasteMyHouse
Dec 21, 2006

JawnV6 posted:

So how many weeks of your time are you planning on burning before even checking the performance of regexes over the ASCII?

1. I was exploring options in completing the task assigned to me, which was to attempt to read the binary formatted files
2. The 'performance' issues were not with parsing the files, but with hspice itself generating them. I was dubious myself, but the engineer who assigned this to me told me that hspice runs noticeably slower when outputting results as ASCII, and also there are some binary results files that he doesn't want to have to regenerate as ASCII for convenience reasons.

But anyway I've already convinced him that reverse engineering the binary format is a waste of time, and synopsys has refused to give us the spec, so I'm working on the ASCII format right now :P

TasteMyHouse
Dec 21, 2006

Neslepaks posted:

Actually the combinations will be persisted in a key-value store or something like that. My idea was to be able to restart the application and have it pick up where it left off, without it having to store any state. It's no problem to achieve this as long as I accept that the picks come out in a linear fashion, but I was hoping there was some clever trick to introduce the illusion of randomness to this scheme.

Thanks for all the replies so far. :)

I do not understand why you don't like the natural ordering of the data.

1337JiveTurkey
Feb 17, 2005

For a set of n strings, a•x+b (mod n) for any a relatively prime to n forms a permutation for values of x on the interval [0,n). This will reduce clustering and you just need to remember a, x and b for that permutation. True randomness with an even probability distribution is tougher since it requires storing the whole permutation or at least its indexes.

defmacro
Sep 27, 2005
cacio e ping pong

GregNorc posted:

So I''m trying to use subset() in R to remove inelligible participants from some study data.

subset(lShare, yob >= 1994 & shares_yn=="Yes" & time_in_country >= 5)

Which returns nothing. I think the issue is I need to specify a SELECT statement, but I'm unsure how to specify I want to return all columns (I tried * and ALL to no avail...)

subset() returns all columns by default, you don't need to specify it with select:
code:
> subset(airquality, Ozone > 40 & Day == 1, select=colnames(airquality))
    Ozone Solar.R Wind Temp Month Day
1      41     190  7.4   67     5   1
62    135     269  4.1   84     7   1
124    96     167  6.9   91     9   1
> subset(airquality, Ozone > 40 & Day == 1)
    Ozone Solar.R Wind Temp Month Day
1      41     190  7.4   67     5   1
62    135     269  4.1   84     7   1
124    96     167  6.9   91     9   1
Are you sure your subset formula is correct and your data.frame contains rows that satisfy your formula?

EDIT: Not sure how I missed the earlier post.

defmacro fucked around with this message at 20:27 on Dec 1, 2011

Johnny Cache Hit
Oct 17, 2011

Neslepaks posted:

Actually the combinations will be persisted in a key-value store or something like that. My idea was to be able to restart the application and have it pick up where it left off, without it having to store any state. It's no problem to achieve this as long as I accept that the picks come out in a linear fashion, but I was hoping there was some clever trick to introduce the illusion of randomness to this scheme.

Thanks for all the replies so far. :)

Seriously -- what is the purpose of this code? I'm really quite curious now, but beyond just curiosity, if you give a little more information about what you are looking to accomplish there might be a different avenue that we can suggest that isn't "store a metric ton of data".

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Kim Jong III posted:

Seriously -- what is the purpose of this code? I'm really quite curious now, but beyond just curiosity, if you give a little more information about what you are looking to accomplish there might be a different avenue that we can suggest that isn't "store a metric ton of data".

Yeah, this strikes me as a "put down the chocolate-covered banana and step away from the European currency systems"-type situation.

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.

Neslepaks posted:

Actually the combinations will be persisted in a key-value store or something like that. My idea was to be able to restart the application and have it pick up where it left off, without it having to store any state. It's no problem to achieve this as long as I accept that the picks come out in a linear fashion, but I was hoping there was some clever trick to introduce the illusion of randomness to this scheme.

Thanks for all the replies so far. :)

What about building a balanced-as-possible binary tree where each node contains the information (leftChild, rightChild, string), such that leaf nodes could be identified by checking for string!=null and branch nodes would have string==null.

When that's done, you'd pass your search algorithm an integer value and use each successive bit in that integer to determine which child branch to search down, stopping when you hit a node with string!=null. So say if we start at the root, you'd look at bit0 of the integer and go left if it was 0, or right if it was 1. At the next level of the tree, look at bit1 and do the same thing. Keep going until you hit a node where string!=null and then return that string.

By itself that would produce lots of strings that would repeat in a way you don't want, so also introduce a hardcoded seed value (with special attention paid to the low-order bits) that you would XOR with the passed in integer, then use the result of that operation to traverse the tree as described above. Deterministic but still pseudo-random.

To get all your two-string entries you'd concatenate the results of searching with input 0 and 1, 1 and 2, etc. Same for the 3+ string entries. When your program is stopped and re-started, look at your key-value store and use the number of entries to determine where to pick up in the search.

I think this should work for trees with 2^n string entries, but you might get some repeated values otherwise. Does that bother you or can you live with checking if an entry is in your key-value store and just continuing on if it already exists?


I'm also curious what the heck you're doing - it seems odd to be fine with storing gigabytes of key-value store data while also being unwilling to store a handful of bytes indicating where you are in your search.

PDP-1 fucked around with this message at 05:53 on Dec 2, 2011

Mr. Crow
May 22, 2008

Snap City mayor for life
What is "Binary Hexadecimal" format? My google-fu has failed me. The entire context

quote:

the value must be encoded in binary hexadecimal format as received... i.e. the data must not be modified in any way.

Right now we're just assuming it literally, that it's encoded hex, but I can't help but think it's like BCD or something and you have to do some weird transformations to it.

Adbot
ADBOT LOVES YOU

nielsm
Jun 1, 2009



Mr. Crow posted:

What is "Binary Hexadecimal" format? My google-fu has failed me. The entire context


Right now we're just assuming it literally, that it's encoded hex, but I can't help but think it's like BCD or something and you have to do some weird transformations to it.

It might be that someone is thoroughly confused about how computers work and they just meant to write that the data must be written as binary. (Although it would be a good idea to specify endianness too.)
"It appears as hexadecimal when I inspect it with my hex editor."

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