What I want to do is for each value in the first column of the first file (lets call it x) I want to print the last column in the 2nd file if the 5th column begins with x.
So for the above, the first value in the first column of the first file is 20. None of the column4 values in the 2nd file begin with 20 so I don't want to print anything. For 33 from the first file I would want to print the value in the last column of the 2nd file for each line e.g 34,34,34,254,254,34.
I have this, it works but my CPU usage for this process is about 30%! Is there a way to make this more efficient?
If you know a way to make this more efficient I'd be grateful!
how can I find cpu usage memory usage swap usage and
I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times
my final destination is monitor process
logical volume usage above X % and number of Logical voluage above
can I not to... (3 Replies)
Hi Friends, I have a tuff time with regular expressionss. Please let me know how to make this happen as it consumed lots of my time but in vain. Here is the sample text file i need to match for. I need to search for pattern1 removed, if it matches then search for pattern types either SE\ or... (2 Replies)
using perl
Hi All, i was wondering if anyone can solve how to extract the full tag from the xml line ie not sure what to put in the m// to get the string
"/data/TOP471//context_data/instruments.txt"
I basically want the above filename in a variable for further processing...
$_ =" ... (0 Replies)
I have an array and two variables as below,
I need to check if $datevar is present in $filename.
If so, i need to replace $filename with the values in the array.
I need the output inside an ARRAY
How can this be done.
Any help will be appreciated. Thanks in advance. (2 Replies)
Hi,
I am trying to write a script which parses a log file and will eventually put the values in an array so that I can perform some math on it. In this file I am only interested in the last 200 lines so here is the command I use to display the contents in a manageable manner.
tail -200... (3 Replies)
Hi Experts,
I am executing multiple instances(in parallel) of perl script on HP-UX box.
OS is allocating substantial amount of CPU to these perl processes,resulting higher cpu utilization.
Glance always shows perl processes are occupying majority of the CPU resource. It is causing slower... (2 Replies)
Hi all,
i have a peice of Perl script like this:
foreach (@line) {
@tmp = split /;/,$_;
#print "Line is: $_\n";
switch($tmp){
case m/p60/i {
push @p60, , $tmp ];
... (7 Replies)
Help needed urgently please.
I have a large file - a few hundred thousand lines.
Sample
CP START ACCOUNT
1234556
name 1
CP END ACCOUNT
CP START ACCOUNT
2224444
name 1
CP END ACCOUNT
CP START ACCOUNT
333344444
name 1
CP END ACCOUNT
I need to split this file each time "CP START... (7 Replies)
This basic code works.
I have a very long list, almost 10000 lines that I am building into the array. Each line has either 2 or 3 fields as shown in the code snippit. The array elements are static (for a few reasons that out of scope of this question) the list has to be "built in".
It... (5 Replies)
Discussion started by: sumguy
5 Replies
LEARN ABOUT SUSE
fuzzy
math::fuzzy(n) Tcl Math Library math::fuzzy(n)
__________________________________________________________________________________________________________________________________________________NAME
math::fuzzy - Fuzzy comparison of floating-point numbers
SYNOPSIS
package require Tcl ?8.3?
package require math::fuzzy ?0.2?
::math::fuzzy::teq value1 value2
::math::fuzzy::tne value1 value2
::math::fuzzy::tge value1 value2
::math::fuzzy::tle value1 value2
::math::fuzzy::tlt value1 value2
::math::fuzzy::tgt value1 value2
::math::fuzzy::tfloor value
::math::fuzzy::tceil value
::math::fuzzy::tround value
::math::fuzzy::troundn value ndigits
_________________________________________________________________DESCRIPTION
The package Fuzzy is meant to solve common problems with floating-point numbers in a systematic way:
o Comparing two numbers that are "supposed" to be identical, like 1.0 and 2.1/(1.2+0.9) is not guaranteed to give the intuitive
result.
o Rounding a number that is halfway two integer numbers can cause strange errors, like int(100.0*2.8) != 28 but 27
The Fuzzy package is meant to help sorting out this type of problems by defining "fuzzy" comparison procedures for floating-point numbers.
It does so by allowing for a small margin that is determined automatically - the margin is three times the "epsilon" value, that is three
times the smallest number eps such that 1.0 and 1.0+$eps canbe distinguished. In Tcl, which uses double precision floating-point numbers,
this is typically 1.1e-16.
PROCEDURES
Effectively the package provides the following procedures:
::math::fuzzy::teq value1 value2
Compares two floating-point numbers and returns 1 if their values fall within a small range. Otherwise it returns 0.
::math::fuzzy::tne value1 value2
Returns the negation, that is, if the difference is larger than the margin, it returns 1.
::math::fuzzy::tge value1 value2
Compares two floating-point numbers and returns 1 if their values either fall within a small range or if the first number is larger
than the second. Otherwise it returns 0.
::math::fuzzy::tle value1 value2
Returns 1 if the two numbers are equal according to [teq] or if the first is smaller than the second.
::math::fuzzy::tlt value1 value2
Returns the opposite of [tge].
::math::fuzzy::tgt value1 value2
Returns the opposite of [tle].
::math::fuzzy::tfloor value
Returns the integer number that is lower or equal to the given floating-point number, within a well-defined tolerance.
::math::fuzzy::tceil value
Returns the integer number that is greater or equal to the given floating-point number, within a well-defined tolerance.
::math::fuzzy::tround value
Rounds the floating-point number off.
::math::fuzzy::troundn value ndigits
Rounds the floating-point number off to the specified number of decimals (Pro memorie).
Usage:
if { [teq $x $y] } { puts "x == y" }
if { [tne $x $y] } { puts "x != y" }
if { [tge $x $y] } { puts "x >= y" }
if { [tgt $x $y] } { puts "x > y" }
if { [tlt $x $y] } { puts "x < y" }
if { [tle $x $y] } { puts "x <= y" }
set fx [tfloor $x]
set fc [tceil $x]
set rounded [tround $x]
set roundn [troundn $x $nodigits]
TEST CASES
The problems that can occur with floating-point numbers are illustrated by the test cases in the file "fuzzy.test":
o Several test case use the ordinary comparisons, and they fail invariably to produce understandable results
o One test case uses [expr] without braces ({ and }). It too fails.
The conclusion from this is that any expression should be surrounded by braces, because otherwise very awkward things can happen if you
need accuracy. Furthermore, accuracy and understandable results are enhanced by using these "tolerant" or fuzzy comparisons.
Note that besides the Tcl-only package, there is also a C-based version.
REFERENCES
Original implementation in Fortran by dr. H.D. Knoble (Penn State University).
P. E. Hagerty, "More on Fuzzy Floor and Ceiling," APL QUOTE QUAD 8(4):20-24, June 1978. Note that TFLOOR=FL5 took five years of refereed
evolution (publication).
L. M. Breed, "Definitions for Fuzzy Floor and Ceiling", APL QUOTE QUAD 8(3):16-23, March 1978.
D. Knuth, Art of Computer Programming, Vol. 1, Problem 1.2.4-5.
BUGS, IDEAS, FEEDBACK
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category math ::
fuzzy of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may
have for either package and/or documentation.
KEYWORDS
floating-point, math, rounding
math 0.2 math::fuzzy(n)