HDTenEightyP/NetNews huggingface dataset:
From: tmjones@eos.ncsu.edu (@large(Are you Object-Oriented?))
Subject: Questions
Originator: tmjones@c00538-106ps.eos.ncsu.edu
Reply-To: tmjones@eos.ncsu.edu (@large(Are you Object-Oriented?))
Organization: North Carolina State University, Project Eos
Date: Wed, 27 Jan 1993 20:54:31 GMT


Great News group, just found it.
Question1: How can I calculate large factorials like (90!)?

Question2: Is there something like Maple that I can get source code to.
           Or possibly a book on some of maple's algorithms like how does
          it take derivatives in the function form?
-- 
------------
Tommie Miles Jones                    North Carolina State University
                                      Computer Science
From: alby@access.digex.com (Albatross)
Newsgroups: comp.programming
Subject: Re: Virus Programs 4 Sale  (Virus, Trojans, etc)
Date: 28 Jan 1993 05:39:02 -0500
Organization: Express Access Online Communications, Greenbelt, MD USA
NNTP-Posting-Host: access.digex.com


  Tom, Looks like your out ta burn me since there's nothing else
you can do to stop me..   Well best wishes....



							Albatross


Newsgroups: comp.programming
From: chens@elec.canterbury.ac.nz (S. Chen)
Subject: Which is superior, BRIEF 3.1 or BC++ 3.1 IDE ?
Organization: University of Canterbury, Christchurch, New Zealand
Date: Wed, 27 Jan 1993 01:52:34 GMT

Hi,
	Is anyone has experience with the Borland's BRIEF 3.1. I have 
been using the IDE (Integrated Development Environment) which comes with
the Borland C++ 3.1. I think this version of IDE is fascinating but like to
find out more about BRIEF 3.1. Does BRIEF 3.1 provide any advantage over
the IDE of BC++ 3.1? Which is superior in term of coding tool? Any advise or
comment will be very much appreciated.

	Please email your comments to me if possible. Thanks for your time
and assistance.

Regards,
Shiun.
27 Jan 1993.
email:chens@elec.canterbury.ac.nz
Newsgroups: comp.programming
From: murphy@sscdaq.phy.bnl.gov (Michael Murphy)
Subject: Re: is it possible to find max & next smallest in one pass?
Organization: Brookhaven National Laboratory  Upton, NY
Date: Mon, 25 Jan 1993 22:42:00 GMT


>jos@and.nl (Jos Horsmeier) writes:

>>In article <asean.727858796@armstrong.ecn.purdue.edu> asean@armstrong.ecn.purdue.edu (Sean Ahern) writes:
>>|jagrant@emr1.emr.ca (John Grant) writes:
>>|>Given an array of values, is it possible to find the maximum of
>>|>the array and the next smallest value in a single pass?  The reason
>>|>I want it in one pass, is that the array is actually a data file
>>|>of a million float values.
>>|
>|If you were able to do this, the algorithm should be able to extend to the
>|next smallest, and the next, with little or no trouble.
>|
>|But the requirement of the algorithm was to do this in one pass.  This would
>|give us an O(n) sorting algorithm that works on arbitrary data.  I don't
>|believe such an animal exists with only one processor.
>
>I beg to differ here. Lets do some big Oh calculations. Given n elements
>in an array, one can find the maximum value in O(n) operations. One can 
>find the next value in O(n) operations too, so both can be done in 
>O(n)+O(n)= O(2*n) operations. But constants don't count here, so the
>whole job can be done uisng O(n) operations. 

This is true, however the first and second largest (smallest) elements of 
an array using can be computed using only n+lg(n)-1 comparisons.  For 
n approximately equal to a million, this is about 1,000,020 comparisons as
opposed to 2,000,000.  (Observe that as n increases the lg(n) term becomes 
negligable).

(This was a homework problem in my algorithms course last year.  If nobody 
gets it in a week, I'll post the solution).

 asean@armstrong.ecn.purdue.edu writes:

>I suppose a good way to find the k smallest elements of an array would be
>to do a O(n*logn) sort and then pull off the smallest k elements.  Though I
>must admit that if you only want the first 2 smallest, the O(2*n) algorithm
>would be better for n>4.

The problem of finding the k-smallest elements of an array is often called 
"Selection."  Algorithms exist that can perform Selection in guaranteed 
linear time.  However they are more of theoretical importance than of practical
concern because of restrictive constants inside of the big-O (see Corman, 
Rivest, et al "Introduction to Algorithms" for a description of one such
algorithm).  A practical Selection algorithm is nicely described in 
Sedgewick's "Introduction to Algorithms."  The idea is based on the Quicksort 
partitioning method.  In the average case, this algorithm runs in linear time, 
but, like Quicksort, can be as bad as O(n^2) if the data is already in sorted 
order.


Michael Murphy
Newsgroups: comp.programming
From: Dave Dodson <dodson@convex.COM>
Subject: Re: Questions
Originator: dodson@bach.convex.com
Date: Thu, 28 Jan 1993 00:11:45 GMT
Reply-To: dodson@convex.COM (Dave Dodson)
Organization: Engineering, CONVEX Computer Corp., Richardson, Tx., USA
X-Disclaimer: This message was written by a user at CONVEX Computer
              Corp. The opinions expressed are those of the user and
              not necessarily those of CONVEX.

In article <1993Jan27.205431.16177@ncsu.edu> tmjones@eos.ncsu.edu (@large(Are you Object-Oriented?)) writes:
>
>Question1: How can I calculate large factorials like (90!)?

The following bc program does it:

f=1
for(i=2;i<=91;i++) { f*=i }
f
135200152767840296255166568759495142147586866476906677791741734597153\
6707715599947656852839547504494277511683367680081920000000000000000000\
00

(bc, a UNIX program, is an arbitrary-precision arithmetic engine.)

----------------------------------------------------------------------

Dave Dodson		                             dodson@convex.COM
Convex Computer Corporation      Richardson, Texas      (214) 497-4234
From: dave@cs.arizona.edu (Dave Schaumann)
Newsgroups: comp.programming
Subject: Re: how about PRIME numbers ?
Date: 24 Jan 93 05:53:43 GMT
Reply-To: dave@cs.arizona.edu (Dave Schaumann)
Organization: University of Arizona

In article <peterd.727578786@tscc2>, peterd@tscc2 writes:
>Ok, I asked for an algorithm for PI (and got several responses - thank you)
>
>How about an efficent algorithm for PRIME numbers ?

Well, for generating lists of 'em, there's always the Sieve of
Erasthonese (sp?).  Not especially fast, but you really only need
to run it once...

For testing primality (or prime factoring), here's a fairly obvious
algorithm I came up with a long time ago:


int is_prime( unsigned long n ) {

  unsigned long i, max = sqrt(n) ;

  if( n <= 3 ) return 1 ;

  if( n % 2 == 0 || n % 3 == 0 ) return 0 ;
  for( i = 6 ; i <= max+1 ; i += 6 )
    if( n % (i-1) == 0 || n % (i+1) == 0 ) return 0 ;

  return 1 ;
  }

This works on two observations:

  1. If a number is not prime, it must have a factor less than or
     equal to its square root.

  2. Once you've checked for division by 2 and 3, there is a simple
     pattern for checking every 2 out of 6 possibilities thereafter
     (similar to the way once you check for division by 2, you only
     need to check for division by odd numbers)

Theoretically, the second observation could be extended to include
more prime factors.  In practice, the pattern of candidate divisors
is much more complicated (eg, for 5, the pattern length is 2*3*5=30
numbers long), and the actual savings is increasingly small.

On the other hand, this seems reasonably adequate.  On a (lightly
loaded) Sequent Symmetry, I used this algorithm to find the 194
primes between 0xfffff000 and 0xffffffff (inclusive) in just over
20 seconds.

I'm not sure that you can do better than this; I believe that there
is at least one encryption method based on the fact that factoring
very large numbers is highly time-consuming (ie, not practical beyond
a certain point).

-- 
Dave Schaumann			dave@cs.arizona.edu
Newsgroups: comp.programming
From: VAAGA@gribb.hsr.no (Vaaga, Hans Egil       7-93)
Subject: Sound effect program
Organization: Rogaland University Centre
Date: Thu, 21 Jan 1993 13:03:47 GMT

Hi!

I don't know if this is the right group to send this letter, but 
I hope you can give me some help anyway.

I'm going to make a program in The Microsoft Windows enviroment. It's a 
tool that operates the synthesizer in a sound card (e.g. Pro Audio
Spectrum 16). It will make the card play sounds like an explosion, type-
writer click etc.

Does it exists programs like this? I'm also interested in books, magazines,
etc. that have conections to this program I'm going to make.

I hope somebody will answer me.

Hans Egil Vaaga
vaaga@gribb.hsr.no
Hans Egil Vaaga
Rogaland University Centre
vaaga@gribb.hsr.no
From: mtoms@ems.cdc.com (Mark Toms)
Newsgroups: comp.programming
Subject: Maximum file size for MS-DOS
Date: 21 Jan 93 22:11:33 GMT
Reply-To: mtoms@ems.cdc.com
Distribution: usa
Organization: Empros Systems International, a division of CDC

I need some help concerning reading/writing a binary data file to disk using
Microsoft C Version 6.01 on a MS-DOS based machine.

I created a file using fopen and began writing records to it.  I used
fclose when I was done.  This part seems to work fine.

However, when I began reading records (fseek, followed by fread) from 
the file, fread failed when I got to about 65535 into the file.  I
noticed that size_t is an unsigned int (16 bits??).

Does anyone have any ideas how to write a data file (about 3 Meg) to
disk?  Am I using the wrong functions?

Any help would be appreciated.

Thanks,
Mark

==========================================================================
J. Mark Toms                                email: mtoms@ems.cdc.com
Baltimore Gas & Electric, Company
C/O Empros Systems International            Phone: (612) 553-4423
2300 Berkshire Lane North                     FAX: (612) 553-4018
Plymouth, Minnesota  55441-3694 USA      Mailstop: PLY060
==========================================================================
From: ganapath@plains.NoDak.edu (Prabhukumar Ganapathy)
Newsgroups: comp.programming
Subject: Request for DATE/TIME library
Date: 24 Jan 93 19:03:20 GMT
Article-I.D.: ns1.C1DGxK.FxE
Organization: North Dakota Higher Education Computing Network


Hi Nettors,

This is my first posting in the newsgroup. I am developing
a database module for my project in C. I would like to
support DATE and TIME formats in my fields. I am looking
for some public domain DATE / TIME library in C with
source code which I can use in my package. I would prefer
the one written in ANSI C standary as I am devloping this
package for both DOS and UNIX.

I can also purchase one if it doesn't cost too much.

Any help in this regard will be highly appreciated.

Please send your response to me by e-mail. I will
post a summary if there is enough interest.


my e-mail : ganapath@plains.nodak.edu


PK
From: lowry@watson.ibm.com (Andy Lowry)
Subject: Re: how to calculate PI
Date: Thu, 21 Jan 1993 18:33:03 GMT
Disclaimer: This posting represents the poster's views, not necessarily those of IBM
	<c8h3xpm@rpi.edu> <bosullvn.727615765@unix1.tcd.ie>
	<LOWRY.93Jan21124521@rotor.watson.ibm.com>
Organization: IBM T.J. Watson Research Center

In article <LOWRY.93Jan21124521@rotor.watson.ibm.com> lowry@watson.ibm.com (Andy Lowry) writes:
 > A straightforward implementation does the following to compute
 > atan(1/x):

Oops... I should have called it a "straightforward but incorrect
implementation." :-)

The algorithm I presented would compute f(x) = x - x^3/3 + x^5/3*5 -
x^7/3*5*7 + ...

The correct algorithm, expressed this time in something similar to C,
is as follows (the type "extended" is intended to mean an extended
precision fixed point number, represented as a vector of ints with an
implied decimal point between the 1st and 2nd elements; both division
of an extended by a normal int, and addition or subtraction of two
extended's can be performed in O(n) time, as indicated in my earlier
post, where n is the size of the vector representing an extended
value):

extended atanrecip(x) /* compute atan(1/x) */
int x;
{
  extended sum, t1, t2;
  int i;

  sum = 0;
  t1 = x;
  i = 1;
  while (t1 != 0) {
    t1 /= x^2;
    t2 = t1;
    t2 /= (2*i-1);
    if (i%2 == 0)
      sum -= t2;
    else
      sum += t2;
    i += 1;
  }
  return sum;
}

Then you compute pi via:

  extended pi;
  pi = 4*(4*atanrecip(5)-atanrecip(239));

The running time is, as it was for the algorithm I first posted,
O(n^2), and if variable i in atanrecip needs to become an extended the
running time becomes O(n^3).  (OK... i would never really be an
extended, since its presumed decimal point would not be between the
1st and 2nd vector elements... but you know what I mean!)
--
Andy Lowry, lowry@watson.ibm.com, (914) 784-7925
IBM Research, P.O. Box 704, Yorktown Heights, NY  10598
Newsgroups: comp.programming
From: mroussel@alchemy.chem.utoronto.ca (Marc Roussel)
Subject: Re: is it possible to find max & next smallest in one pass?
Organization: Department of Chemistry, University of Toronto
Date: Mon, 25 Jan 1993 17:38:48 GMT

In article <1jt96b$kc9@agate.berkeley.edu> bsmith@mickey.NoSubdomain.NoDomain
(Brian Smith) writes:
>/* Keep max2 >= max1 */
>max1 = max2 = x[0];
>for (i=1; i<N; i++) {
>    if (x[i] > max1) {
>	if (x[i] > max2) {
>	    max1 = max2;
>	    max2 = x[i];
>	} else {
>	    max1 = x[i];
>	} 
>    }
>}
>/* At this point, max2 is largest, min1 is next largest */

     The initialization is dangerous.  What if x[0] is the largest value?

				Marc R. Roussel
                                mroussel@alchemy.chem.utoronto.ca
Newsgroups: comp.programming
From: hjv@phil.ruu.nl (Hendrik Jan Veenstra)
Subject: Re: is it possible to find max & next smallest in one pass?
Organization: Department of Philosophy, University of Utrecht, The Netherlands
Date: Sun, 24 Jan 1993 15:48:02 GMT

black@seismo.CSS.GOV (Mike Black) writes:

>In article <1993Jan24.040702.6193@emr1.emr.ca> jagrant@emr1.emr.ca (John Grant) writes:
>>Given an array of values, is it possible to find the maximum of
>>the array and the next smallest value in a single pass?  The reason
>>I want it in one pass, is that the array is actually a data file
>>of a million float values.
>>
>>If so, I guess the same single pass could also find the min and next
>>highest value too?
>>

>	for (i = 2; i < 1000; i++) {
>		value = random() / 1000.0;
>		ivalue(value > max1) { /* New max and demote old one */
>			max2 = max1;
>			max1 = value;
>		}

And what if 'value' lies *between* max1 and max2...?  Suppose you have to
check for that too...
So, supposing max1 is the biggest of the two, this would yield something like

         if (value > max1)
         {
            max2 = max1;
            max1 = value;
         }
         else if (value > max2)
         {
            max2 = value;
         }


--
Hendrik Jan Veenstra    hjv@phil.ruu.nl  *  How can I save my dreams
Dept. of Philosophy                      *  in the nightmare, in the flood
University of Utrecht                    *  But I try.
The Netherlands                          *
From: ivan@erich.triumf.ca (Ivan D. Reid)
Newsgroups: comp.programming
Subject: Re: is it possible to find max & next smallest in one pass?
Date: 24 Jan 1993 07:29 PST
Organization: TRIUMF: Tri-University Meson Facility
Distribution: world
NNTP-Posting-Host: erich.triumf.ca
News-Software: VAX/VMS VNEWS 1.41    

In article <51915@seismo.CSS.GOV>, black@seismo.CSS.GOV (Mike Black) writes...
]Seems to me that life is simpler than everyone makes it :-)

]Why compare BOTH numbers??  If we find a new max, then the old max is
]obviously the next highest, isn't it?? The same would follow for however
]many maxes you wish to find.  No more than one comparison necessary.
	Unfortunately, no.  See comments below.


]/* Finds the maximum and next-maximum of of first 1000 pseudo-random numbers. 
] * We'll divide by 1000.0 just to get a floating point number. 
] * Add a similar primer and one more if-check and you can find the min 
] *   and next-min too. 
] */

]main()
]{
]	float value, max1, max2, tmp;
]	int i;
]	max1 = random() / 1000.0; /* Prime the pump */
]	max2 = random() / 1000.0;
]	if (max1 > max2) { /* Swap the first two if necessary */
]		tmp = max1;
]		max1 = max2;
]		max2 = tmp;
]	}
]	for (i = 2; i < 1000; i++) {
]		value = random() / 1000.0;
]		ivalue(value > max1) { /* New max and demote old one */

	Presume you mean "if (value > max1)..."
	But what happens if max1>value>max2?  :-(

]			max2 = max1;
]			max1 = value;
]		}
]	}
]	printf("%g %g\n", max1, max2);
]}

Ivan Reid, Paul Scherrer Institute, CH.     			ivan@cvax.psi.ch
From: spackman@disco-sol.dfki.uni-sb.de (Stephen Spackman)
Newsgroups: comp.programming
Subject: Re: hashing floating-point numbers
Date: 23 Jan 1993 16:16:56 GMT
Organization: DFKI Saarbruecken GmbH, D-W 6600 Saarbruecken
Reply-To: stephen@acm.org
NNTP-Posting-Host: disco-sol.dfki.uni-sb.de
In-reply-to: pefv700@chpc.utexas.edu's message of Fri, 22 Jan 93 17:57:23 GMT

In article <1993Jan22.175723.17245@chpc.utexas.edu> pefv700@chpc.utexas.edu (Christopher Phillips) writes:

|What are the usual methods for hashing floating-point numbers
|given that numbers "equivalent" to a certain precision should
|hash to the same value?

If you think about the equivalence classes that you have in mind for a
moment, you'll realise that this probably isn't a good idea anyway.
Consider the following algorithm for your problem (which isn't usably
efficient and doesn't have good statistical properties, but shows the
problem up neatly):

problematicFloatHash
  [ (epsilon	:: Float),	.. the difference defining "equivalence"
    (hash 	:: UninterpretedBinary(size Float) -> Hash),
				.. an arbitrary hash function for the bits
    (x		:: Float)	.. the input value
  ]
: .if x = x + epsilon
  .then hash x
  .else problematicFloatHash[epsilon, hash, x + epsilon]
  .

Basically all numbers with an exponent small enough that they can
represent a difference of your epsilon will have to hash to the same
value; if you choose a value for epsilon like 10^6, and you have, say,
48 bits in your mantissa, all numbers absolutely less than something
like 2^48/10^6 ~ 2^28 will get folded together!

The problem is much worse if the error is expressed in relative terms:
quite likely this model will be continuous, and *all* numbers will have
to hash to the same value.

More likely what you want to do is round the things to a multiple of
your bucket size *before* hashing them, and make sure that the context
of use of your algorithm isn't sensitive to off-by-one errors in choice
of bucket. (Of course, that's what fixed-size representations are all
about).
----------------------------------------------------------------------
stephen p spackman    +49 681 302 5288(o) 5282(sec)    stephen@acm.org
      dfki / stuhlsatzenhausweg 3 / d-w-6600 saarbruecken 11 / germany
----------------------------------------------------------------------
Newsgroups: comp.programming
Subject: Re: is it possible to find max & next smallest in one pass?
From: jeremy@cs.aukuni.ac.nz (Jeremy Gibbons)
Date: Thu, 28 Jan 1993 01:06:59 GMT
Organization: Computer Science Dept. University of Auckland
Cc: jeremy@cs.aukuni.ac.nz

In <1993Jan25.224200.7195@bnlux1.bnl.gov> murphy@sscdaq.phy.bnl.gov (Michael Murphy) writes:

>>jos@and.nl (Jos Horsmeier) writes:

>>>In article <asean.727858796@armstrong.ecn.purdue.edu> asean@armstrong.ecn.purdue.edu (Sean Ahern) writes:
>>>|jagrant@emr1.emr.ca (John Grant) writes:
>>>|>Given an array of values, is it possible to find the maximum of
>>>|>the array and the next smallest value in a single pass?  
>>>|
>>|If you were able to do this, the algorithm should be able to extend to the
>>|next smallest, and the next, with little or no trouble.
>>|
>>|But the requirement of the algorithm was to do this in one pass.  This would
>>|give us an O(n) sorting algorithm that works on arbitrary data.  I don't
>>|believe such an animal exists with only one processor.
>>
>>I beg to differ here. Lets do some big Oh calculations. Given n elements
>>in an array, one can find the maximum value in O(n) operations. One can 
>>find the next value in O(n) operations too, so both can be done in 
>>O(n)+O(n)= O(2*n) operations. But constants don't count here, so the
>>whole job can be done uisng O(n) operations. 
>
>This is true

No, it isn't. Or at least, not in the way you think. Generalising the
obvious algorithm for finding the largest two elements out of n to an
algorithm for finding the largest k elements out of n leads to O(nk)
comparisons (keeping a sorted list of the k largest so far), or to O(n log
k) (keeping a balanced binary tree of the k largest so far), in the worst
case. This is only O(n) if k is considered fixed, not part of the problem.

Put another way: if you allow yourself arithmetic with big Os, then
   O(n)+O(n) = O(n)
   O(n)+O(n)+O(n) = O(n)
etc, but
   O(n)+O(n)+...+O(n) [k times]  is not  O(n)
Which just goes to show that you can't trust arithmetic with big Os. :-)

>>I suppose a good way to find the k smallest elements of an array would be
>>to do a O(n*logn) sort and then pull off the smallest k elements.  Though I
>>must admit that if you only want the first 2 smallest, the O(2*n) algorithm
>>would be better for n>4.
>
>The problem of finding the k-smallest elements of an array is often called 
>"Selection."  Algorithms exist that can perform Selection in guaranteed 
>linear time.  

Actually, "Selection" refers to finding the (single) kth-smallest element,
not to all k smallest elements. I don't know of any way of finding all k
smallest elements for arbitrary k in O(n) comparisons in the worst case.
(Information-theoretic arguments show that you can't find all k smallest
elements for arbitrary k in O(n) comparisons in the worst case *and* return
them in sorted order, because then you could sort in O(n) comparisons.)

Jeremy

---
Jeremy Gibbons <jeremy@cs.aukuni.ac.nz>         tel: +64 9 373 7599
   Department of Computer Science,              fax: +64 9 373 7453
   University of Auckland, Private Bag 92019, Auckland, New Zealand.