Programming :: Adding Two Arrays?

Mar 1, 2010

I have a problem on a program,the problem take a very long time when i try to add two big arrays element by elementI know that matlab make adding vectors more faster than adding element by element but I don't know how!!!do any body knew how matlab make vectors operations more faster than element by element???I want to make my calculation more faster because the program is very big

View 8 Replies


ADVERTISEMENT

Programming :: Arrays In The C Programming Language Are Pointers To The First Element Of The Array?

Mar 27, 2010

I wonder why arrays in the C programming language are pointers to the first element of the array, not the first element of the array itself?

View 14 Replies View Related

Programming :: Character Arrays In C?

Nov 3, 2010

I was reading Kernighan Ritchie book chapter 4 which deals with character pointers.I am not able to understand following different type of declarations

Code:
char aname[][15] = { "Illegal month", "Jan", "Feb", "Mar" };
char amessage[] = "now is the time";

[code]...

View 1 Replies View Related

Programming :: Using Of Arrays In Loops?

Sep 3, 2009

need to process files within multiple directories and transfer these to a remote server. What I had in mind was to use arrays for this; code pasted below (explains it better):

Code:
#set the arrays
array_A=( fileA* pathtodestA hostA passwordA )

[code]...

View 8 Replies View Related

Programming :: Can Diff Take Arrays As Input

Jun 19, 2010

Does diff not like arrays? How do achieve the following?

Code:

stuart@stuart:~/music transfer$ diff file1.txt file2.txt
1c1
< bonkers_in_phoenix.mp3

[code]....

View 14 Replies View Related

Programming :: Initializing Arrays In The Bash?

Mar 12, 2009

I'm making script for automated compiling of one program which would output builds optimized for many architectures. For clearancy, I do each build in it's own catalogue and list of builds with their respective catalogues would be stored as array. I'm using this guide as reference. It describes making array as naming a variable with additional brackets denoting it's position in array.

In my code, it looks exactly like this:

Code:

mtune[1]="build/mtune/athlon"
mtune[2]="build/mtune/athlon-4"
mtune[3]="build/mtune/athlon-mp"

[code]....

But upon invoking $mtune or any $mtune[x] variable, output is blank, like the variable(s) were never initialized. What am I doing wrong?

View 1 Replies View Related

Programming :: Printing 2 Arrays To 2 Columns?

Jun 16, 2010

I have a Perl script that has two arrays - they are related. I would like to print out the contents into two columns next to each other.

#!/usr/bin/perl
open(PINGFILE, </home/casper/pingdata.txt") or die " can not open file ";
my @totalfile=<PINGFILE>;
foreach $string(@totalfile) {
if ($string =~ m/(^1sping)(?=.*max))/) {
push(usecstring,"$string");

[Code]...

View 2 Replies View Related

Programming :: Structures And String Arrays, C?

Apr 18, 2011

I am working on a project that needs to use structures and I'm pretty sure string arrays. First I declare my structures and they must be exactly like this.

typedef struct
{
int hour;

[code]....

View 4 Replies View Related

Programming :: Create A Small Array Of 3x3 Arrays?

Jul 12, 2009

I'm trying to figure how to create an small array of 3x3 arrays such I can do

Code:

SUM1(i) = SUM1(i) + SUM2

where i goes from 1 to 8 and SUM2 is a 3x3 array.

View 2 Replies View Related

Programming :: Read Text File Using Arrays In C++?

Oct 19, 2010

a project using bluetooth to send data byte by byte to external devices buti'm not familiar using arrays to read file from another location before sending the data.If you could,do correct my codes.Here's my code,

void loop(){
char Msg[]={"Hello"};
char *start;

[code]...

View 2 Replies View Related

Programming :: Get Number Of Elements In A Hash Of Arrays?

Dec 10, 2008

I have something like this:

$arr_hash{'produce'}{'veggies'}[0] = Broccoli
$arr_hash{'produce'}{'veggies'}[1] = Cauliflower
$arr_hash{'produce'}{'veggies'}[2] = Carrots

[code]...

View 2 Replies View Related

Programming :: Perl - Pointers To Arrays From Hashes?

Feb 18, 2010

I'm trying to figure out how to code for this specific type of instance - I want to use a hash and have the key be a reference to an array, and not use the key in the standard way of it being a scalar. Basically, I have a large output that I need to process line by line, and rather have access to it as an array than a big block in a scalar. For the big block hash as a scalar I would do -

Code:
foreach $CONTROLLER (<CONTROLLER_LIST>) {
$ALL_DISKS{$CONTROLLER} = `ssh -n <commands>`;
}

Now I know I could take the scalar and split it to another array after the fact like -

Code:
@TEMP_HOLD = split (/s+/,$ALL_DISKS{$CONTROLLER});

How would I code it that I would have access to the key information as an array and not a scalar? I know it needs to be a pointer and we're going to have -> in there somewhere, but not sure how to approach it. Some of the documentaiton I've been reading about referencing I've found a little confusing so far, and trying to figure out how to use them in context of what I'm working on.

View 1 Replies View Related

Programming :: If Test Validation - Using Char Arrays

Jun 9, 2010

I'm writing a code to get the index of the last occurrence of a given substring in a string.

Code:
int StringHandler::lastIndexOf(string src, const string s) {
unsigned int lastIndex = string::npos;
if (src.find(s, 0) == string::npos) {
return -1; } else {
bool isLast = false; unsigned int i = 0; do {
lastIndex = src.find(s, i);
if (lastIndex != string::npos) { i = lastIndex + 1;
if (i == src.size()) { isLast = true;
} } else { isLast = true;
} } while (!isLast);
} return lastIndex;
}

My problem is: execution steps into an if with a false condition! Check the values of i and src.size() at the right panel. How could be possible for the program to run the highlighted statement? The if condition above is false! [URL]. I could use char arrays, for example, but this kind of false validation has happened to me more than once, I'm using G++ 4.5 with these flags: -O0 -g -Wall -c

View 3 Replies View Related

Programming :: PHP - Sorting Multi Dimensional Arrays By One Column

Mar 17, 2009

I just started programming in PHP so I haven't figured out how to do this yet, but I have a multi-dimensional array that I need to sort by one column. That's fine...but I need the sort to ignore case! Right now I have it sorted by 'name' (the other column is 'uid').

The problem is that by the default the sort is case-sensitive so the array looks like this:
Code:
Apple 4015
Banana 4011
Cherry 4045
avocado 4046

I want to be able to sort the the 'name' column in a case-insensitive manner so that the array actually looks like:
Code:
Apple 4015
avocado 4046
Banana 4011
Cherry 4045

How to accomplish this? Just FYI I'm not actually sorting the PLUs for fruits...but it was a simple example. I'm actually doing this for a Facebook application.

View 2 Replies View Related

Programming :: Bash: Combine Arrays & Delete Duplicates?

May 23, 2011

I would like to combine two arrays and delete duplicates that might occur. I tried to solve it like this:

Code:
combined=( "${results1[@]}" "${results2[@]}" )
printf "${combined[@]}" | sort -n | uniq
Example:
result1 (4 elements):

[Code]....

In my code printf seems to have a problem with elements that have the same letters but a space inbetween. For instance "new foo", "newfoo" are the same for printf

View 5 Replies View Related

Programming :: Bash Scripting Arrays And Indirect Referencing

Feb 23, 2010

I've got a situation. I'm having GNU bash version 3.00.16(1) on Solaris 10. I need to declare an array say arr1 which will be populated by an output of a command.

declare -a arr1
arr1=( $(/some/command) )

Supposing it will eventually (after executing the command) have element values as -

arr1[0]=1234
arr1[1]=5678
arr1[2]=7890

Now, I need to declare another set of arrays, one for each of the element values above - e.g.

declare -a arr1_1234
declare -a arr1_5678
declare -a arr1_7890

And I also need to populate elements of each of above 3 arrays with output of another command in a loop. So, these arrays will hold values something like -

arr1_1234[0]="abc"
arr1_1234[1]="def"
arr1_1234[2]="ghi"

arr1_5678[0]="jkl"
arr1_5678[1]="mno"
arr1_5678[2]="pqr"
arr1_7890[0]="tuv"
arr1_7890[1]="xyz"
arr1_7890[2]="aab"

I'm able to declare and populate arr1[*]. My question is how do I declare, populate and print the subsequent arrays and their elements?I am feeling rather thick to get this working.

View 7 Replies View Related

Programming :: Multi Dimensional Arrays In C Of Variable Size

Apr 15, 2010

I am curious if there is a way to describe and use variable sized multi-dimensional arrays in C using pointers. I mean, for 1-dimensional array e.g. I can use the following piece of code:

...
int i , N;
int *array;
scanf("%d", &N);
array = (int*) malloc(N*sizeof(int));
for (i=0; i<N; ++i) array[i] = i; // Assigning values to the array
for (i=0; i<N; ++i) printf("%d ", array[i]); // Printing the assigned values
free (array);
...

But what about the two dimensional array[N][M] ? I guess I have to use a double pointer e.g: int **array. But how exactly? Note that I use C90 and not C99.

View 2 Replies View Related

Programming :: Getting An Undefined Offset For The Associative Arrays [28-46] In Format

Dec 8, 2010

i'm getting an undefined offset for the associative arrays [28-46] in this format.

[Code]....

i have read that i can prevent the notices by doing the following, but it's not working for me

PHP Code:

[Code]....

View 5 Replies View Related

Programming :: Arrays In Awk - Take Some Data From A File - Ssh Log - And Print It To A Html Table

Feb 7, 2011

I have a problem with arrays in awk. What i want is to take some data from a file (ssh log) and print it to a html table. I have managed to print some stuff (user logged in and how many times they have logged in) What i want more is to take all the ip that each user logged in from and print it in a row next to the username and times (in the code i typed blabbla where i want the ip to be shown. How do you think i should approch that, multidimensional arrys maybe?

Code:

View 14 Replies View Related

Programming :: Adding User Through The Script?

Jun 6, 2010

Im trying to create the following script...I want to create an interactive script that prompts the user for the following:

user name
user home directory
user login shell
user comment

the script then needs to read those variables that are entered by the user and actually create the user account. and of course, would like the script to display what user account was just created so that i know in fact the script worked successful.

View 2 Replies View Related

Programming :: Adding Different Data Types?

Jun 9, 2011

i am searching for a table that gives info about the result of operations (+ , - , * , /) on data types

i mean if we * int by another int, the result should be assign in long so no overflow happens.

something like that.

like what will be the result of mult unsigned int by signed it , is there tables for such operations.

View 6 Replies View Related

Programming :: Adding Directory To The Path?

Apr 2, 2009

I have made the installation of Qt4 in my Fedora/MacBookPro. It also got a first compiling and running a simple program. The point is that for the compiler to run I need to point out every time where the bin is located, as that:

$ /home/threader/kinetic/bin/qmake -project

I have tried the following, but it still doesn't work:

# script
#-----------------------------------------------------------#
# /etc/bashrc or /home/threader/.bash_profile
# config to Qt compiler

[code]....

View 5 Replies View Related

Programming :: Adding Further Function On Sh Script?

Apr 10, 2010

I use following script:-

Code:

#!/bin/sh
# cd Linbread
TODAY=`date +"%m%d"`
DATA=`grep $TODAY linbread.dat`

[code]....

sound file .wav and background .gif are available. Please advise what shall I add to the script to do the job as expected.

View 1 Replies View Related

Programming :: Adding Gtk Libraries To Eclipse Using C

Jan 30, 2010

So I decided to take my first steps into programming with C + gtk. So far I have doneI loaded eclipse and ensured I had the cdt package Created a new C/C++ project called "play" Added a new source file called "Playfullsrc.c" Added the following to paths and symbols (output of the command: pkg-config --cflags gtk+-2.0)

Code:
/usr/include/gtk-2.0
/usr/lib/gtk-2.0/include
/usr/include/atk-1.0
/usr/include/cairo
/usr/include/pango-1.0
/usr/include/pixman-1
/usr/include/freetype2
[Code]....

added "/usr/lib/libgtk-x11-2.0.so" to GCC C Linker Libaries (I have cheacked and this file exists) When I build the project I get the error message "cannot find -l/usr/lib/libgtk-x11-2.0.soplayline 0C/C++ Problem" I have been following this tutorial: [URL]

View 2 Replies View Related

Programming :: Adding Third Colum And Normalizing?

Dec 18, 2010

I have a file for plotting contour graph in gnuplot.The data in the fine as below:Quote:

1 1 3
1 2 7
1 3 6

[code]....

View 9 Replies View Related

Programming :: Adding Mod-Perl And Using Apache ASP?

Sep 16, 2010

I have a debian lenny machine that I am trying to add mod_perl to and use apache asp on. I have had a range of failures on it. Is ther a way I can build apache2 with mod_perl in it? Instead of separate. Apache2 is built with some modules built in by default, how can I make mod_perl one of them?

View 1 Replies View Related

Programming :: Adding Some Code To Like 50 PHP Files

Jan 15, 2010

I need to basically add some code to like 50 php files. It's basically a script that I want to add near the end of these 50 php files. I figured I could use sed to replace </body> with the code. However the code, is very long and has a bunch of newlines obviously. How would I be able to do this?
sed -e 's/<//body>/(all the text)/' *.php

Since it has newlines, I don't know how to paste it in cause it would take me to a '>' prompt without allowing me to complete the sed command. I want to insert this code.
Code:
<br><br>
<center>
<form action="test.php" method=post>
<textarea name="comments" cols=40 rows=6>

View 3 Replies View Related

Programming :: Adding Functionality To Perl Script?

Mar 18, 2011

I am a C++ programmer and never used Perl. add a functionality to a script, in Perl language. Originally, the script takes 1 file input and I run it in this way: ./script.pl file1 It is designed to return specific words from that file, example:

user
admin
printer-1
user-2
server

The idea is that I need to be able to provide the script with a second input file that contains only few words, each on a new line. These words might have a "dash". Example:

printer-2
server
user-2

I will be running the script as: ./script.pl file1 file2 In return, the script should check if every word in file1 does exist in file2. If it does exist, then the script displays it. In the example I provided above, the script should only return:

server
user-2

Here is the script I have. What's in black is the original working Perl script and what's in red is what I would like to add in Perl Language:

!/usr/bin/env perl
my ($table);
for (every value in file2)
{

[code]....

View 7 Replies View Related

Programming :: Adding Strlcpy() Function To Library?

May 2, 2011

I am running on windows, i don't have strlcpy() function as it's not a standard function, so i want to add it to my library, i know how to do that thankfully ^_^This is the function:

Code:
/*$OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $*/
/*

[code]....

View 4 Replies View Related

Programming :: Adding Job From Script (Custom Built RPM)

Mar 10, 2011

I'm building an RPM that requires adding a cron job into a user's(service account) crontab...from what I see in the manpages, this isn't possible, as the only viable option is to replace the crontab entries already there for previous scripts being run. Either way, as an example I've found I can make it work by directly modifying the crontab file using:

Code:
echo "* * * * * /bin/ls -la ~/ >> ~/ls.log" >> /var/spool/cron/userName

I'd just like to know, is there any MAJOR issues with modifying a the crontabs like this? This is running on a Redhat Enterprise Linux server by the way.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved