Multiply elements of 2 arrays together into another array
So I need to Write an array processing program using a Linux shell programming language to perform the following.
Load array X of 20 numbers from an input file X.
Load array Y of 20 numbers from an input file Y.
Compute array Z by multiply Xi * Yi then compute the square-root of this computation.
What I have done so far is loading the input file X.txt and Y.txt into array X & Y. I try to compute the multiplication and insert it into array Z but I keep getting a syntax error. This complicates me from moving on to compute the square root of the elements in Z.
Hi,
Please can someone help to return the array elements from a function. Currently the problem I face is that tempValue stores the value in myValue as a string while I need an array of values to be returned instead of string.
Many Thanks,
Sudhakar
the function called is:
... (5 Replies)
PHP question...I posted this on the Web Development forum, but maybe this is a better place!
I have an SQL query that's pulled back user IDs as a set of columns. Rather than IDs, I want to use their names.
So I have an array of columns $col with values 1,7,3,12 etc and I've got an array $person... (3 Replies)
Hi all,
I wanted to access two arrays (of same size) using one for loop.
Ex:
#!/bin/bash
declare -a num
declare -a words
num=(1 2 3 4 5 6 7)
words=(one two three four five six seven)
for num in ${num}
do
echo ":$num: :${words}:"
done
Required Output:
:1: :one: (11 Replies)
How can I get my array to understand the double-quotes I'm passing into it are to separate text strings and not part of an element? here's what I'm working with...
db2 -v connect to foo
db2 -x "select '\"' || stats_command || '\",' from db2law1.parallel_runstats where tabname = 'BAZ'"
set... (4 Replies)
Hi I have two arrays :
@arcb= (450,625,720,645);
@arca=(625,645);
I need to remove the elements of @arca from elements of @arcb so that the content of @arcb will be (450,720).
Can anyone sugget me how to perform this operation?
The code I have used is this :
my @arcb=... (3 Replies)
hello,
i need a bit of help on how to do this effectively in bash without a lot of extra looping or massive switch/case
i have a long array of M elements and a short array of N elements, so M > N always. M is not a multiple of N.
for case 1, I want to stretch N to fit M
arrayHuge
H = (... (2 Replies)
Hi All,
need help with reading the array and sum of the array elements.
given an array of integers of size N . You need to print the sum of the elements in the array, keeping in mind that some of those integers may be quite large.
Input Format
The first line of the input consists of an... (1 Reply)
I need your help to discover missing elements for each box.
In theory each box should have 4 items: ITEM01, ITEM02, ITEM08, and ITEM10.
Some boxes either have a missing item (BOX02 ITEM08) or might have da duplicate item (BOX03 ITEM02) and missing another one (BOX03 ITEM01).
file01.txt
... (2 Replies)
I'm looking for an efficient way to sum elements from 2 arrays using AWK and preserve header as well as sample names in the output array. I have Ubuntu 16.04 LTS. For example;
ARRAY 1
SAMPLE DERIVED ANCESTRAL
Sample1 14352 0
Sample2 14352 0
Sample3 14352 0
Sample4 ... (8 Replies)
EV(1) General Commands Manual EV(1)NAME
ev - evaluate expressions
SYNOPSIS
ev 'expr' ..
DESCRIPTION
Ev evaluates expressions given on the command line, and sends the results to the standard output, one per line. An expression contains
real numbers, function calls, and the following operators:
+ - * / ^
Operators are evaluated left to right, except '^', which is right associative. Powers have the highest precedence; multiplication and
division are evaluated before addition and subtraction. Expressions can be grouped with parentheses. All values are double precision
real.
The following library of functions is available:
if(cond, then, else)
if cond is greater than zero, then is evaluated, otherwise else is evaluated.
select(N, a1, a2, ..)
return aN (N is rounded to the nearest integer). If N is zero, the number of available arguments is returned.
rand(x) compute a random number between 0 and 1 based on x.
floor(x) return largest integer not greater than x.
ceil(x) return smallest integer not less than x.
sqrt(x) return square root of x.
exp(x) compute e to the power of x (e approx = 2.718281828).
log(x) compute the logarithm of x to the base e.
log10(x) compute the logarithm of x to the base 10.
sin(x), cos(x), tan(x)
trigonometric functions.
asin(x), acos(x), atan(x)
inverse trigonometric functions.
atan2(y, x)
inverse tangent of y/x (range -pi to pi).
EXAMPLE
To pass the square root of two and the sine of .5 to a program:
program `ev 'sqrt(2)' 'sin(.5)'`
AUTHOR
Greg Ward
SEE ALSO icalc(1), rcalc(1)RADIANCE 10/28/96 EV(1)