Programming :: Numpy 'filter' Type Function?

Jan 27, 2010

I'm a n00b to both numpy and python. I was wondering what the most intelligent way to write the trapezoid rule function was:

Code:
>>> import numpy as np
>>> a=np.array([1,2,3,4,5])
>>> def mytrapz(vec):
total=0
for i in xrange(0,len(vec)-1):
total+=(vec[i]+vec[i+1])/2.0
return total

>>> mytrapz(a)12.0 This is exactly what I would do in C and I'm sure the for loop is not the fastest way (as is the case for my interpreted langs). Yes, I know there is already numpy.mytrapz... I'm interested in the most efficient way to loop over arrays in such a way that each iteration accesses more than one cell.

View 1 Replies


ADVERTISEMENT

Software :: Openoffice.org Plugin Or Filter For Visio Type Files?

Mar 28, 2010

From MS-Word, there are certain graphics that one can create that feature linked boxes of text (I think they're referred to as smart graphics, or something). There's another MS program called visio that also creates these type of graphics. When I tried to open a docx file that had one of these graphics in it with openoffice.org (I'm using version 3.1 from debian backports on my lenny system), it was unable to read it. Is there a plugin or filter that I can add to openoffice.org to give it this functionality? If not, is there another program that reads these files?

View 2 Replies View Related

Programming :: How Can A Friend Function Access A Public Function From A Base Class

Nov 16, 2010

Code:
#include <iostream>
using namespace std;

[code]...

View 1 Replies View Related

Programming :: Passing Data From Interrupt Handler Function To Tasklet Function?

May 18, 2010

I am doing some Linux kernel programming for my research project. I need to record the timestamp (by using cpuid and rdtsc) when an interrupt handler (top half) is first invoked. Due to the time critical nature of the problem itself, I have to do the timestamping inside the interrupt handler itself (the first operation when the handler is called). However, I understand that tasks that are not so time critical should be deferred to a tasklet function (bottom half) for processing because other interrupts are disabled in a (top-half) interrupt handler. I am currently out of idea on how I can pass the timestamp information that I have obtained in the interrupt handler to the corresponding tasklet function.

View 2 Replies View Related

Ubuntu Multimedia :: Use The "filter All Layers" Function?

Feb 15, 2010

I installed the gimp-gap package from the repositories. When I attempt to use the "filter all layers" function I get multiple errors, and the plugins are not available to me.

Errors:
Code:
GIMP Message
Calling error for procedure 'gimp-procedural-db-proc-info':
Procedure 'plug-in-diffraction-Iterator' not found
GIMP Message
Calling error for procedure 'gimp-procedural-db-proc-info':
Procedure 'plug-in-solid-noise-Iterator' not found

[Code]...

View 4 Replies View Related

Programming :: Error - Array Type Has Incomplete Element Type

Jan 26, 2010

I'm trying to compile a program and it gives me the following:

I checked cmath-util.h:46 and cmath-util.h:48:

I'm not a C person, and the author is unavailable so far.

View 5 Replies View Related

Programming :: Declaring A Function In A Function - C Programming

May 24, 2010

I want to declare a function in a function, but had no success till now, see the error code below and visit the project at sourceforge

[Code]...

View 14 Replies View Related

Programming :: Bash Array Add Function Example Using Indirect Array Reference As Function Argument?

Jun 20, 2010

I looked on the net for such function or example and didin't find anything, thus after having made one i guess it would be legitimate to drop it to see what others thinks of it.

#!/bin/bash
addelementtoarray()
{
local arrayname=$1

[code]....

View 10 Replies View Related

Programming :: Bash: Using Grep To Filter 25 Or Above?

Dec 3, 2010

i have a sample that looks like this:

Code:
[schneidz@hyper temp]$ wget -q --output-document=- http://world.needforspeed.com/SpeedAPI/ws/game/nfs-w/leaderboards/events

[code]....

View 2 Replies View Related

Programming :: Filter ASCII Characters PHP?

Mar 8, 2010

How can I filter ASCII quotes( ' ) and double quotes ( " ) so that I can replace them with the UTF-8 equivalent?If I copy text from a Word Document(ASCII), and upload it to a web page with PHP. The Database(UTF-8) will replace these racters with incorrect character(s).I need some function that will replace these characters but I don't know how to differentiate the ASCII quotes and the UTF-8 Quotes without (somehow) converting the string to hex, then preg_replace'ing the hex code for the symbol.

View 8 Replies View Related

Software :: Install Numpy-1.6.0b2 On Machine?

Apr 25, 2011

I'm trying to install numpy-1.6.0b2 on my Linux machine and I'm having a lot of trouble. After downloading the source files, I try to build with the gfortran compiler. I receive a massive list of errors, most non-fatal, until I reach the following -

[Code]...

I've been working at this for quite some time and nothing I have found online seems to work. I know it's a longshot but I was wondering if anyone has had this same problem and has found a way to fix it.

View 2 Replies View Related

CentOS 5 :: Upgrade Python And Numpy Using Yum?

Aug 1, 2009

I would like to update Python v.2.4 and Numpy to Python v.2.6 and Numpy v.1.3. How can I do it. I heard that we can use "yum update", but I am not sure to do it correctly.

View 2 Replies View Related

Programming :: Filter Last 24 Hour Data And Put In New File?

Aug 30, 2010

i have file server 1 (filesvr01acess.log) and disc server 1 (discsvr01acess.log) in unix box(say ip adress of the box 10.39.66.81)
Similiarly i have file server 2 (filesvr01acess.log) and disc server 2(discsvr01acess.log) in unix box(say ip adress of the box 10.39.66.82). Now my requirement is write sheel script for ..

1. I need only last 24 hour data out of the file server 1 and file server 2 and then finaly put this data in one new file

2. Similiarly same need for discserver 1 and discserver 2.

FYI, each .log files mentioned above is nicely order as date and time as it is created. I can view through cat or search by using grep comand in unix I am wondering if we can achieve through grep command in unix

View 1 Replies View Related

Programming :: Convert The String Data Type To Other Primitive Data Type?

Mar 4, 2011

I am trying to generic way to convert the string datatype to other primitive data type. To achieve, i used Template . But i getting error and couldn't resolve the issue and error reported is also clueless.

Code
====
#include <vector>
#include <iostream>
#include <string>

[Code].....

View 7 Replies View Related

Ubuntu Installation :: Unable To Install Numpy?

Sep 13, 2010

I am running Ubuntu 10.04 (64-bit) with python 2.6 and have had great difficulties with the installation of numpy and matplotlib (matplotlib needs numpy). I have tried several different approaches --- but unsuccessful still. I have downloaded the following:

* python-numpy_1.4.1-4_amd64.deb
* python-numpy_1.5.0-1ppa1_amd64.deb
* numpy-1.5.0.tar.gz

and,

* matplotlib_0.99.3-1ubuntu1.debian.tar.gz
* matplotlib_0.99.3.orig.tar.gz
* matplotlib-1.0.0.tar.gz

(I gave up on matplotlib 1.0.0) How can I install numpy with matplotlib? I have attached a python script to test the installation.

View 2 Replies View Related

Programming :: Filter Out The Additional Packages That Exist On A New Server?

Apr 15, 2010

I've got two files. They both contain package names. Is there any way I can go through the package list on one file, and search to see if each package exists in the other file? What I'd want to do, is if the package name is found in the the main file, then go to the next line. If its not found then print that package name to another file.

I know you can use diff, but it doesn't seem to be that straight forward. As I understand it diff searches line by line, so if line one doesn't match line one in another file, then it prints it out. That's not exactly what I want.

I just really need an easy way to filter out the additional packages that exist on a new server. If I have a list of packages that aren't on the original server, then i can just delete them.

Not sure if I've made any sense but there must be a quicker way to do what i need to. It would take me ages to scan manually through the package names in each list, and highlight the ones i dont need.

View 2 Replies View Related

Programming :: Find Syntax Exclude Certain Extensions And Filter By Age

May 26, 2010

I'm trying to find all the files in a specified directory that do NOT end in .archived or .error and are older than 30 mins. Currently I have: Code: find /opt/edi/incoming -type f ! ( -name "*.archived" -name "*.error" ) -cmin 30 But I keep returning files that end in those extensions and I'm not sure if I'm using -cmin correcty? If there is a better way to do this (perl, etc) I'm open to options, this is for a nagios check.

View 2 Replies View Related

General :: Filter Script Files In Bash Programming?

Feb 10, 2010

I'm building my first BASH programs and I have a hard time. I can't do a search in a folder and filter only script files without extension, the problem is to differentiate the script files from the others. I tried with ls I tried with find and i don't find a way to make it work.

View 8 Replies View Related

Programming :: JFileChooser : Setting The Default 'file Filter'

Sep 28, 2010

Code:

// create a filechooser;
JFileChooser chooser = new JFileChooser(cwd);
FileNameExtensionFilter filter = new FileNameExtensionFilter(
"sdf files (*.sdf)", "sdf");

[code]....

This will give 3 filefilters ('all files', 'sdf files' and 'xml files') for a fileopen dialog. Exactly as I want (in alphanumerical order), but XML is the default extension and I like SDF to be the default extension. Research has not revealed solutions; the setFileFilter method sets the primary filter. If I swap the sequence in the code, SDF becomes the default (as I want) but the sequence is wrong (All, XML, SDF).

View 3 Replies View Related

Programming :: Unable To Exclude Lines And Bad Filter Within AWK Script

Apr 29, 2010

Looking for some help to fix 2 problems I have in my script. (I�m using bash on cygwin)I have the following source file ($7 does not have data):

Code:

HEADER_1,HEADER_2,HEADER_3,HEADER_4,HEADER_5,HEADER_6,HEADER_7
pattern2,pattern7/Sub data1/Sub data2,pattern8,pattern9,pattern2,pattern2,
pattern3,pattern6/Sub data1/Sub data2,pattern7,pattern3,pattern5,pattern1,

[code]....

In line 5 of the script, that is " {$2 !~ /pattern4|pattern5|pattern6/ }" oriented to delete lines containing pattern4, pattern5 and pattern6 from column 2 it seems not to be working. If I see the output, the line highlighted in red, is present and should not appear, because this line does not contain nor HEADER nor pattern1 nor pattern2.

View 7 Replies View Related

Programming :: Unknown Filter Error - Option Rate Unparsable

Feb 21, 2010

I am getting this error "Unknown filter "police", hence option "rate" is unparsable. This is in Linux Kernel 2.6 which is compiled with the "policing" option enabled in Qos (Kernel config). The error seems to be coming from the file tc.c in iproute2/

static int parse_nofopt(struct filter_util *qu, char *fhandle, int argc, char **argv, struct nlmsghdr *n) {
__u32 handle;
if (argc) {
fprintf(stderr, "Unknown filter "%s", hence option "%s" is unparsable
", qu->id, *argv);
return -1;
} if (fhandle) {
struct tcmsg *t = NLMSG_DATA(n);
if (get_u32(&handle, fhandle, 16)) {
fprintf(stderr, "Unparsable filter ID "%s"
", fhandle);
return -1; }
t->tcm_handle = handle; }
return 0; }

This is called from get_filter_kind() which is called from tc_filter_modify(), called from do_filter(), from do_cmd() from main()...all in tc.c. Is this a known "bug" in iproute2+2.6 as the 2.4 Kernel works with the same settings?

View 14 Replies View Related

Programming :: Surface Fitting Using NR Function Svdfit ( ) In C Programming?

Sep 16, 2010

fit a surface i.e. W(x,y) using svdfit() provided by "Numerical Recipes in C". svdfit() is written for curve fitting and not for surface fitting.But one can use svdfit(), as claimed by authors of NR book, to do surface fitting. On page 680 of NR book, authors have given a hint on how to use svdfit() for fitting a surface. But I have not understood it.This link may be helpful (Chapter 15 th is relevant here.):[URL]This is my problem:

Code:
I have a set of 100 numbers. I want to fit a 2-Dimensional function W(x,y) to these numbers.

[code]....

View 2 Replies View Related

Programming :: Calling An Asm Function From C?

Jun 4, 2010

I have a question about calling an asm function from C....It doesn't work unless I create an asm variable to hold the value of the function in....Why?Here's the code that doesn't work...

asmfile.s - version one Code: .section .data
mydata: .ascii "this is the message!
.equ mylen, . - mydata

[code]...

View 2 Replies View Related

Programming :: Using Backtrace() Function In C?

Jul 23, 2010

I want to use backtrace() function to debug a crash issue. I tried this sample code to see how backtrace works. backtrace() function always returns 0 with the below code. Is there any kernel configuration that needs to be set for proper working of backtrace?

#include <execinfo.h>
#include <stdio.h>
#include <stdlib.h>
/* Obtain a backtrace and print it to stdout. */
void
print_trace (void)

[Code]...

View 2 Replies View Related

Programming :: How To Write / Use Function

May 30, 2010

Can you offer me the code about fmod() in C. I want to know how this function work, i am very interested in it because i have no idea to implement it, i want to know... how to write the function... not 'how to use the function' can anyone post the source codes of this function here?

View 6 Replies View Related

Programming :: Accessing C Function From C++

Jul 5, 2010

i have an open source application that was developed in C++ (it uses objects and namespaces all over the place). I also have another application that was developed in C. Now i am trying to insert the code made in C into C++ application, but when i do that , i get this error on compilation of the source code:

Code:
error: 'mpi_init_vars' was not declared in this scope the function mpi_init_vars() is not part of object oriented programming and it doesn't belong to any scope, it was compiled into an object file and i am linking it with all objects of C++ application.

How can invoke the C function from C++ object oriented code?

View 2 Replies View Related

Programming :: Bash Function Using If / Then And Else

May 2, 2011

I am trying to build a function inside a script.

Code:
#!/bin/sh
#System commands and other configurable.
IPT=/sbin/iptables
IP6T=/sbin/ip6tables
IPST=/usr/sbin/ipset
MODP=/sbin/modprobe
GET=/usr/bin/wget
INT_NET=192.168.1.0/24 .....

I can find lots of tutorials in how to use if, then, else. However, how do I define a variable inside the function?
SEE>>
Code:
for c in $ISO
Also, am I using the 'test' command correctly( -/+ week as valid test)?

View 7 Replies View Related

Programming :: Calling C Function In Php?

Feb 7, 2011

I am doing a web site program and what I need is to call a C program in the PHP cloud.Do u think it would be possible? The web site would get the user input from PHP UI and pass to the C program , the C program would process the function with the user input and output the a PHP page.

View 2 Replies View Related

Programming :: C++/c Function Is Uable To Know Its Name?

Jan 4, 2011

I ask if a c++/c function is able to know its name from inside itself:

example:

Code:
int funct1(int a,b)
{
printf("%s ",funct_name());
}
or with a trick.

View 2 Replies View Related

Programming :: Run 'time' On A Function?

May 30, 2010

Code:
#!/bin/ksh
(...)
# FILL UP PARTITION
diskfillerfunction () {

[Code]....

Test 15: fill up partition /usr/bin/time: cannot run diskfillerfunction: No such file or directory

I am obviously omitting (...) a lot of the code, but the relevant part is all there. How do I 'time' a function?

View 5 Replies View Related







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