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
Hootie Hoo
Nov 13, 2008

by angerbot
edit: so there's a php question thread is there

Hootie Hoo fucked around with this message at 23:31 on Apr 30, 2010

Adbot
ADBOT LOVES YOU

DrBouvenstein
Feb 28, 2007

I think I'm a doctor, but that doesn't make me a doctor. This fancy avatar does.
I'm wondering if there is a way to do what I'm thinking in MATLAB:


I have several static text boxes I made in GUIDE with names like box1, box2, box3, etc...

I'd like to be able to easily change the strings inside them with a loop, something like:

code:
for i = 1:3
    set(handles.boxi, 'String', num2string(i));
end
but I can't figure out how to actually refer to box1, box2, etc.. in the loop. Just using "boxi" makes MATLAB think there is a text box with the tag "boxi," not the current value of i.

Karter705
Sep 20, 2004
I HAD TO SPEND $10 TO TELL THIS DUDE HIS IDEAS ABOUT DOG BREEDING ARE RETARDED BECAUSE ~*HUG ISLAND*~
I have a gallery of images I'm building, there is to be 8 images per gallery. I am dynamically generating these pages so I never know how many images total there will be when I run the program. I want each gallery to link to other galleries so I need to know the current gallery so I can link to the rest of the galleries. I have a variable numTotalGalleries and a variable i which is the current IMAGE number (starting at 0).

How can I calculate the current gallery with that information?


Here is the code I have, if it is needed: http://pastie.org/941860


Edit: Duh, figured it out.

You have X number of images. A gallery holds Y images. You therefore have ceil(X / Y) galleries.

for any variable i indicating which image, from zero, you want to see, your gallery will be (again, from zero) floor(i / Y)

Karter705 fucked around with this message at 22:32 on May 1, 2010

Jose Cuervo
Aug 25, 2004
I am writing a program in Visual Studio (C++) (this is my first time really using pointers) and I finally have it at the point where I am running big problems on it. Running big problems slows my system way down - my music player halts while the program is running, etc.
From looking at Windows Task Manager, it seems like at some points up to 1,500,000K in the Memory (Private Working Set) is being used by my program. Is this an accurate measure of the amount of memory (RAM) my program is using? And is this an indication that I have memory leaks due to the fact that I have not deleted all pointers I created? I went back and made sure to add delete statements after I was done with any pointer I have created, but this continues to be a problem. Ideas?

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Yes, your program is using a lot of memory. The first step to getting help lowering it is to tell us what a "big problem" entails and how your program solves them.

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.

Jose Cuervo posted:

And is this an indication that I have memory leaks due to the fact that I have not deleted all pointers I created?

Maybe, maybe not. Have you tried estimating how much memory your Big Problem should be using?

For example if you have an object that is about ~1kb in size and you make an array of 10 of them, finding out that your program is taking up a gigabyte of memory indicates a problem. If you take the same 1kb object and make a 1024x1024 2D array then using a gig of memory is just the natural consequence of storing that much data.

Jose Cuervo
Aug 25, 2004

PDP-1 posted:

Maybe, maybe not. Have you tried estimating how much memory your Big Problem should be using?

For example if you have an object that is about ~1kb in size and you make an array of 10 of them, finding out that your program is taking up a gigabyte of memory indicates a problem. If you take the same 1kb object and make a 1024x1024 2D array then using a gig of memory is just the natural consequence of storing that much data.

My code has two parts - part one develops a lower bound for a schedule using a network flow approach, and part two is a schedule builder. If I run the program without using the lower bound computation, the maximum memory used by the program is 60,000K. If I use the lower bound computation, then the program takes 1,500,000K.
The network flow computation requires me to have 7 different long int arrays. For the problem I am running, on average they are of size 1x10,000. The network flow code is called 17 times for the problem, and the memory being used increases by 80,000K-120,000K each time the network flow code is called (which is how the program ends up using 1,500,000K total). But I am calling the delete function on all 7 arrays each time I am done with a call to the network flow code, so in my mind the amount of memory I am using should be 60,000K+120,000K at the very maximum, and should fluctuate between 180,000K if the network flow code has been called and the arrays are being used, and 60,000K if the network flow code has deleted the arrays.
Is this not correct thinking?

Let me know if you need more information.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Are you calling delete or delete []

Jose Cuervo
Aug 25, 2004

Mustach posted:

Are you calling delete or delete []

I call delete if I have a pointer declared as
code:
int *myIntPtr= new int;
and I call delete [] if I have a pointer declared as
code:
int* *myIntArrayPtr= new int*[numMachines];
So in my code, I have:
code:
int *myIntPtr= new int;

*myIntPtr= 77;

delete myIntPtr;
and
code:
int numMachines= 10;

long int *myIntArrayPtr= new long int[numMachines];
long int* *myIntArrayPtr2= new long int*[numMachines];

for (int i=0; i<numMachines; i++)
{
   myIntArrayPtr[i]= i;
   myIntArrayPtr2[i]= new long int[numMachines];

   for (int j=0; j<numMachines; j++)
   {
      myIntArrayPtr2[i][j]= j;
   }
}

//Delete the arrays

delete [] myIntArrayPtr;

for (int i=0; i<numMachines; i++)
{
   delete [] myIntArrayPtr2[i];
}

delete [] myIntArrayPtr2;
Is my usage of the delete function not correct?

tractor fanatic
Sep 9, 2005

Pillbug
arg I screwed this all up

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
Has anybody here really looked into embedding a language interpreter into another program? I was hoping Parrot had gotten far along but it looks like a lot of the code generator for it for other languages aren't complete, and it's hard to come by how to expose a common API that these languages could all use. Instead I was thinking about embedding Python since there seems to be some documentation and history behind doing that. But of course I know some Python so I would be looking there. Are there better languages more suitable? I also know of the Spidermonkey Javascript implementation that is meant for embedding.

Edit: I guess I should say the host program would be in C++; that would be pretty important.

Lonely Wolf
Jan 20, 2003

Will hawk false idols for heaps and heaps of dough.
Lua was specifically designed for embedding in a program. It's interface is C but there's probably some C++ wrapper somewhere.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Yes there is it is called Luabind and I used to work on it.

ToxicFrog
Apr 26, 2008


Seconding the Lua recommendation. The interface is callable from C++, and there are also a bunch of C++ native binding libraries/tools - see here under "C++".

It has a few other properties that make it attractive for embedding, too - primarily that it's small, it's easy to learn, and it's MIT licensed.


If for some reason Lua doesn't fit your needs, I've also seen Python and Guile (a Scheme implementation) used in a few places, but don't know much about either.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I've had terrible experiences finding bugs in a Lua interpreter embedded in a benchmark I have to deal with at work to the point that I wanted to act like Lua didn't exist. That's completely irrational though so I have to concede the point that it is made for this kind of thing. I guess the trick is whether or not I'd be more likely to throw something at an embedded Lua interpreter than, say, a Python one.

clockwork automaton
May 2, 2007

You've probably never heard of them.

Fun Shoe
General implementation question: What's the best method for checking collisions in 2D of an object-oriented bounding box and an axis aligned ones?

The current code is using slopes and x and y intersects of lines on the BBs. I'm currently considering implementing separating axis, but I'm not sure if this is the best direction to go. (The current method does fail occasionally)

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Honestly, it sounds like you're pretty close to using separating axis already. I'd go with that off the top of my head.

(Also you probably don't mean "object-oriented bounding box".)

clockwork automaton
May 2, 2007

You've probably never heard of them.

Fun Shoe

Avenging Dentist posted:

Honestly, it sounds like you're pretty close to using separating axis already. I'd go with that off the top of my head.

(Also you probably don't mean "object-oriented bounding box".)

I don't. I'm just exhausted.

Peao
Dec 1, 2004
If you can read this, remind me of why I shouldn't post.
Is there some sort of complete, GUI-driven subversion server installer for Windows?

I tried VisualSVN Server but it's a buggy POS, it doesn't detect the users I create (always stays at 0 users no matter how many I create). I know they're there because when I try to create an account with the same name as one from before, it tells me that account already exists. Of course, I still can't log in with said account.

There MAY be Collab.net but what sort of company asks you to register before you can get to an installer? I'm staying well clear.

I know Subversion is easy to set up, but I'd rather an integrated installer, like how some people make LAMP/WAMP packages. Maybe I'm getting old but I'm sick of reading tutorials on how to set up everything from the command-line and editing this and that conf file then this and that password file. Hopefully someone out there has already done this for me so I can have everything set up in 5 minutes.

Yeah I know I sound like an rear end.

Edit: this is for home use, obviously I'd be more hands-on if it were important.

Peao fucked around with this message at 01:57 on May 7, 2010

Avenging Dentist
Oct 1, 2005

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

Peao posted:

There MAY be Collab.net but what sort of company asks you to register before you can get to an installer? I'm staying well clear.

God who cares

Peao
Dec 1, 2004
If you can read this, remind me of why I shouldn't post.
^^^ I do. I have no way to tell if it's free for use or a 30-day trial. Nothing on the website gives any indication of this. Additionally, Bugmenot has them on their "blocked sites" list for some reason (WHY?) so I can't do a quick sign up. It's not worth it to spend 10-15 minutes creating an email address for them to spam when I can just asked informed people here if there's a decent, non-retarded solution that works out there. And finally, I just plain don't want to encourage that forced sign-up behavior.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
http://www.mailinator.com/

God forbid a company wanting to know the tiniest thing about you before giving their work away for free.

NeilPerry
May 2, 2010
I've got a VBA question

I'm working on an access application for school. Most of it is finished but I still need to figure out how to add a picture to a table.It's basically "questionnumber, question, image". The image field is an Attachment. I should be able to add the image from a form, resize it and show it whenever the question comes up during the quiz I programmed but I can't figure out how. Any help or push in the right direction would be appreciated!

ToxicFrog
Apr 26, 2008


Peao posted:

I know Subversion is easy to set up

:pwn:

Compared to what?

More seriously, you'll probably get more help in the version control megathread. Be prepared for lots of people telling you (correctly) to use git/bzr/hg instead, though.

stephenm00
Jun 28, 2006
Fixed

stephenm00 fucked around with this message at 15:23 on Apr 21, 2017

Mr.Hotkeys
Dec 27, 2008

you're just thinking too much

stephenm00 posted:

I am sorry if this is an obvious question but I don't frequent the cavern of COBOL as I have no programming experience. However, I am looking to hire a web developer to create a fairly simple web application. How would I find someone to do this? Should I make a thread, or just try contacting people in the "goons for hire" thread?

Thanks

That, or you could try SA Mart. I've seen quite a few threads like that there.

UZR IS BULLSHIT
Jan 25, 2004
I'm writing a code in Fortran where I have to call a particular subroutine a large number of times. The code of the subroutine is seen below (I got it from Numerical Recipes in Fortran):

code:
! **************************************************
!
      SUBROUTINE FFT(DATA,NN,ISIGN)
!
! **************************************************

!     Replaces DATA by its discrete Fourier Transform, if ISIGN is input as 1;
!         Or replaces DATA by NN times its inverse discrete Fourier Transform, 
!         if ISIGN is input as -1.
!     DATA :  Complex array of length NN, or Real array of length 2*NN
!     NN   :  Length of discrete Fourier Transform ( multiple of 2 !! )

      REAL*8 WR,WI,WPR,WPI,WTEMP,THETA
      REAL*8 TEMPR,TEMPI
      DIMENSION DATA(2*NN)
      N = 2*NN
      J = 1
      DO 11 I=1,N,2
         IF(J.GT.I) THEN
              TEMPR     = DATA(J)
              TEMPI     = DATA(J+1)
              DATA(J)   = DATA(I)
              DATA(J+1) = DATA(I+1)
              DATA(I)   = TEMPR
              DATA(I+1) = TEMPI
         ENDIF
         M = N/2
1        IF ( (M.GE.2).AND.(J.GT.M)) THEN
             J = J-M
             M = M/2
         GOTO 1
         ENDIF
         J = J+M
11    CONTINUE
      MMAX = 2
2     IF(N.GT.MMAX) THEN
         ISTEP = 2*MMAX
         THETA = 6.28318530717959D0/(ISIGN*MMAX)
         WPR   =-2.D0*DSIN(0.5D0*THETA)**2
         WPI   = DSIN(THETA)
         WR    = 1.D0
         WI    = 0.D0
         DO 13 M=1,MMAX,2
            DO 12 I=M,N,ISTEP
               J=I+MMAX
               TEMPR = WR*DATA(J)   - WI*DATA(J+1)
               TEMPI = WR*DATA(J+1) + WI*DATA(J)
               DATA(J)   = DATA(I)   - TEMPR
               DATA(J+1) = DATA(I+1) - TEMPI
               DATA(I)   = DATA(I)   + TEMPR
               DATA(I+1) = DATA(I+1) + TEMPI
12          CONTINUE
         WTEMP = WR
         WR = WR*WPR-WI*WPI+WR
         WI = WI*WPR+WTEMP*WPI+WI
13       CONTINUE
         MMAX = ISTEP
      GOTO 2
      ENDIF
      RETURN
      END
Here is my problem. If I try to pass DATA as a double precision complex (complex*16), it returns a floating point error after about the 2nd time I call it (values in data go to 1E+299). Why would that happen? If I pass DATA as a complex*8, it works fine. What gives?

Edit to explain more what I am doing.

I have an array u of size (n,n,n). I use this routine to calculate the inverse Fourier Transform of u. However, this routine is only for calculating 1D FFTs, and I need to calculate the FFT for all 3 dimensions of u. So I'd have something like:

code:
do k=1,n
     do j=1,n
        call fft(u(:,j,k),n,-1)
     end do
end do
So for a particular choice of j and k, it would transform one row, then the next, etc. (there would also be loops for doing the same on the other dimension). So when I call fft, it should ONLY be manipulating the particular column of data that I gave it, so I don't think it's a cumulative effect from calling fft many times. But I don't know so much about computer science, so I have no idea why fft works for complex*8, but not complex*16.

UZR IS BULLSHIT fucked around with this message at 23:30 on May 7, 2010

Dijkstracula
Mar 18, 2003

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

Look at the Fortran code you pasted. In the loop you're pulling out the real and imaginary components of your data into variables of type REAL*8. So, you'd effectively be assigning the first half of a double-sized value to TEMPR and the other half to TEMPI.

Also, if you're doing this for semi-serious work, don't use anything out of Numerical Recipes, get yourself a real Fourier library like FFTW or something.

UZR IS BULLSHIT
Jan 25, 2004

Dijkstracula posted:

Look at the Fortran code you pasted. In the loop you're pulling out the real and imaginary components of your data into variables of type REAL*8. So, you'd effectively be assigning the first half of a double-sized value to TEMPR and the other half to TEMPI.

Ok...I'm not seeing the problem. Isn't an element of a complex*16 just two real*8's?

quote:

Also, if you're doing this for semi-serious work, don't use anything out of Numerical Recipes, get yourself a real Fourier library like FFTW or something.

I'm in grad school, working on a university-owned computer. I don't have the privileges to install anything on my computer.

BigRedDot
Mar 6, 2008

boeman posted:

I don't have the privileges to install anything on my computer.
If you can compile your own code, you can compile FFTW or anything else and install it locally in your home directory.

Dijkstracula
Mar 18, 2003

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

boeman posted:

Ok...I'm not seeing the problem. Isn't an element of a complex*16 just two real*8's?
Yes it is, my apologies. I misread the code you pasted and confused myself. :) Fortran 77 :downs: (I'd recommend compiling your code with debug info and stepping through your FFT routine to make sure it's doing the sensible things you expect.)

Also, FFTW etc. is a library that you link against when you compile, so there's no need to install anything.

Dijkstracula fucked around with this message at 08:42 on May 8, 2010

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
That's a well-accepted method for setting up makefiles when starting to work with code split across directories? Right now I have Makefiles in each directory for building just that little part for testing, but I'm not sure yet what I'd necessarily want to do when I have a master project and want to have it build everything together. I am assuming I'd call make on the subdirectories to generate the subordinate .o files; that way I can keep my distinct Makefiles. But then I fear I'll rebuild the same source code over and over if it's referred to across different directories.

Say I have Makefiles for directory X and one for directory Y. They both refer to code in directory W. The .o files wind up in X or Y respectively. That would be fine building them on their own. But when I want to build them all, I imagine it would first go into X, pull in files from W, finish up X, go into Y, and wind up pulling the same files from W.

Is it even a big fuss?

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Don't use Makefiles. But if you have to for some reason, use autotools (which is also awful but slightly less so than Makefiles).

Dijkstracula
Mar 18, 2003

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

Wow, I don't think I've ever heard someone suggest autotools over vanilla makefiles. Sure the syntax can be grating ( s/^[ ]+/\t/ :argh: ) but it gets the job done.

AD, if not makefiles, what do you use?

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Makefiles are awful, not very platform-independent, and a pain in the rear end to maintain. I use autotools for work because I have to. Big boys use one of Scons, Cmake, Autotools, MSBuild, or Boost.Build, in rough order of coolness.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Avenging Dentist posted:

Makefiles are awful, not very platform-independent, and a pain in the rear end to maintain. I use autotools for work because I have to. Big boys use one of Scons, Cmake, Autotools, MSBuild, or Boost.Build, in rough order of coolness.
Is that ascending order of coolness left to right, or right to left?

I agree makefiles suck, but what if I want to distribute tarballs. Can I reasonable expect somebody to have the appropriate toolchain on their machine?

mr_jim
Oct 30, 2006

OUT OF THE DARK

Rocko Bonaparte posted:

Is that ascending order of coolness left to right, or right to left?

I agree makefiles suck, but what if I want to distribute tarballs. Can I reasonable expect somebody to have the appropriate toolchain on their machine?

If they are compiling it for themselves, it's not unreasonable to ask them to install the appropriate tools. Presumably, they already have the compiler and libraries. If they have Python installed already, scons is a good choice. Otherwise, go with cmake, or (ugh) autotools.

edit: Or you can look into scons-local. It still requires python on the builder's system, but they don't have to have scons installed. It runs standalone from a directory in your build tree.

mr_jim fucked around with this message at 18:07 on May 10, 2010

Avenging Dentist
Oct 1, 2005

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

mr_jim posted:

Otherwise, go with cmake, or (ugh) autotools.

I'm pretty sure Cmake still requires Cmake to be installed on the system if you want the ability to configure.

mr_jim
Oct 30, 2006

OUT OF THE DARK

Avenging Dentist posted:

I'm pretty sure Cmake still requires Cmake to be installed on the system if you want the ability to configure.

Maybe I was a little unclear. The person building Rocko Bonaparte's program will have to install the necessary tools. How much of a problem that is depends on what tools he chooses, and what the builder already has installed.

The CMake binary packages don't have any dependencies that I am aware of, so installing it isn't much of a hassle. Building CMake from source might require having a previous installation of CMake available.

If he uses Scons, the builder will have to have Python installed, which may or may not be an issue. However, they won't necessarily have to install Scons, since it can run standalone and be included with his code.

Either way, it's worth it to avoid using Makefiles.

Adbot
ADBOT LOVES YOU

Dijkstracula
Mar 18, 2003

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

Scons looks neat; the next time I start a larger project I'll think about using it. If it handles building shared libraries sensibly in a platform-independent way, I'll be thrilled.

Here's hoping I'll never have to write this again.

code:
  8 ifeq ($(shell uname -s), Darwin)
  9     $(CC) $(CFLAGS) utils.c mpica_viz.c mpica.c -dynamiclib -dynamic -compatibility_version 1.0 -current_version 1.0.0     \
 10         -install_name ../lib/libmpica.so.1.0.0 -o ../lib/libmpica.so.1.0.0 $(LIBS)
 11 else
 12     $(CC) $(CFLAGS) utils.c mpica_viz.c mpica.c -shared -Wl,-soname,libmpica.so -o ../lib/libmpica.so.1.0.0 $(LIBS)
 13 endif
:gonk:

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