• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 191
  • Last Modified:

Math Functions In Large Numeric Arrays

I have some large arrays (between 1000 and 2000 spots) Anywho I was wondering is there any functions that can find me the sum, product, sort them (least int to largest int), also the natural log of the array. I know there probally is I just haven't searched much. I just hate these for/loops that I keep running to do val = val + array(x) now that isn't what I'm using they look more like

for x = 1 to iDataIndex
   array(0) = array(0) + val(0,x)
   array(1) = array(1) + val(1,x)
   array(2) = array(2) + val(2,x)
   array(3) = array(3) + val(3,x)
next x

but any functions can help even better for/loops (especially for the product part) anywho thanks in advance,
MoDrop
0
MoDrop
Asked:
MoDrop
  • 2
2 Solutions
 
JacamarCommented:
to sort an array, this is a very basic method

For inJ = 1 to X-1
for inI = 1 to X-1

if myarray(inI) > myarray(inI+1) then
inTemp = myarray(inI)
myarray(inI) = myarray(inI+1)
myarray (inI+1) = inTemp
end if

Next inI
Next inJ

This will compare two array members that are adjacent to each other.  Which ever one is greater, it will move to the bottom of the array.  So after one pass through(or one inJ), you will have the largest element in your array as the last value.  After 2 passes, you will have the largest 2, and ect, until after X-1 passes you will have them sorted from smallest to largest.

I hope this helps.

Jacamar
0
 
JacamarCommented:
To get the natural log of a value, use

dim NatLog() as single

Redim NatLog(1 to X)

For inI = 1 to X

NatLog(inI) = Log(myarray(inI)

Next inI

Jacamar
0
 
CleanupPingCommented:
MoDrop:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
MoDropAuthor Commented:
Project put on back burner. Thanks for trying.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now