Search Results

Search found 2562 results on 103 pages for 'vector'.

Page 82/103 | < Previous Page | 78 79 80 81 82 83 84 85 86 87 88 89  | Next Page >

  • How to get orientation of android from gyrsocope sensor events ?

    - by Pritam
    I am using android 2.3 on Nexus S and want to get orientation from gyroscope sensor events. As gyro gives angular velocity how to use this for getting device orientation ? Also is there any way we can get pure linear accelerations on phone's axis, without gravity vector. I expected this from Linear acceleration sensor event but just found a post and referred android source as well for Sensor which currently uses only accelerometer. So what's the best way to combine the readings from both hardware to get pure accelerations without gravity inclusions ? Thanks.

    Read the article

  • Could not realize media player

    - by user556894
    I am using this code to run avi file using jmf but the error come like "Could not realize media player" and how to open all video format using jmf import javax.media.*; import javax.media.format.*; import java.io.*; import java.util.*; public class Test{ public static void main(String a[]) throws Exception{ CaptureDeviceInfo di = null; Player p = null; Vector deviceList = CaptureDeviceManager.getDeviceList(new AudioFormat("linear", 44100, 16, 2)); if (deviceList.size() > 0){ di = (CaptureDeviceInfo)deviceList.firstElement(); System.out.println((di.getLocator()).toExternalForm()); }else{ System.out.println("Exiting"); System.exit(-1); } try{ p = Manager.createPlayer(di.getLocator()); }catch (IOException e){ System.out.println(e); }catch (NoPlayerException e) { System.out.println(e); } System.out.println("Playing Started"); p.start(); } }

    Read the article

  • Creating matrix of maximum values indices in MATLAB

    - by Gacek
    Using MATLAB, I have an array of values of size 8 rows x N columns. I need to create a matrix of the same size, that counts maximum values in each column and puts 1 in the cell that contains maximum value, and 0 elsewhere. A little example. Lets assume we have an array of values D: D = 0.0088358 0.0040346 0.40276 0.0053221 0.017503 0.011966 0.015095 0.017383 0.14337 0.38608 0.16509 0.15763 0.27546 0.25433 0.2764 0.28442 0.01629 0.0060465 0.0082339 0.0099775 0.034521 0.01196 0.016289 0.021012 0.12632 0.13339 0.11113 0.10288 0.3777 0.19219 0.005005 0.40137 Then, the output matrix for such matrix D would be: 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 Is there a way to do it without catching vector of indices from max function and then putting ones in the right place using for loop?

    Read the article

  • Avoid the use of loops (for) with R

    - by albergali
    Hi, I'm working with R and I have a code like this: i<-1 j<-1 for (i in 1:10) for (j in 1:100) if (data[i] == paths[j,1]) cluster[i,4] <- paths[j,2] where : data is a vector with 100 rows and 1 column paths is a matrix with 100 rows and 5 columns cluster is a matrix with 100 rows and 5 columns My question is: how could I avoid the use of "for" loops to iterate through the matrix? I don't know whether apply functions (lapply, tapply...) are useful in this case. This is a problem when j=10000 for example, because execution time is very long. Thank you

    Read the article

  • C++ Urban Myths

    - by Neil Butterworth
    I'm starting to write an article on what I'm calling "C++ Urban Myths" - that is, ideas and conceptions about C++ that are common but have no actual roots in reality. Some that I've come up with so far are: TR1 is part of standard C++ TR1 (technical Report #1) proposed a whole bunch of changes to C++. Unfortunately, it was never accepted. It is faster to use iterators to access a vector than operator[] Or vice versa. All tests I've carried out indicate the two are nearly identical in performance. The C++ Standard contains something called the STL It doesn't - neither "STL" nor "Standard Template Library" appear in the Standard. I'm wondering if the SO C++ community can come up with any better ones? Ideally, they should be expressible in a single sentence, and not involve any code. Edit: I guess I didn't make it clear enough that I was interested in myths believed by C++ developers, not misconceptions held by non-C++users. Oh well...

    Read the article

  • Accessing typedef from the instance

    - by piotr
    As in stl containers, why can't we access a typedef inside the class from the class instance? Is there a particular insight into this? When value_type was a template parameter it could help making more general code if there wasn't the need to specify the template parameters as in vector::value_type Example: class T { public: typedef int value_type; value_type i; }; T t; T::value_type i; // ok t.value_type i; // won't work

    Read the article

  • How to do animation using swing and clojure ?

    - by Humberto Pinheiro
    I'm trying to animate a chess piece in a board. First I created a java.util.Timer object that "scheduleAtFixedRate" a TimerTask implemented as a proxy function. So I kept a record of the piece to move (piece-moving-record) and when it's apropriate (when the user move the piece using the mouse) the TimerTask proxy function should be test if the record is not nil and execute the piece-moving function. The piece-moving function just updates the x and y coordinates of the piece, according to a vector pre-calculated. I put a add-watch on the piece-moving-record so when it changes it should repaint the board (canvas). The paint method tests if this piece-moving-record is not nil to paint it. The problem is that the animation doesn't appear. The piece just jump to the destiny, without the movement between. There is some problem with the animation scheme ou there is a better way to do it?

    Read the article

  • dose not name a type error in c++

    - by user985316
    #include <math.h> #include <stdlib.h> #include <stdio.h> #include <vector> #define IE 40 #define JE 40 #define KE 40 #define ia 7 #define ja 7 #define ka 7 #define NFREQS 3 using namespace std; main() float l,m,n,i,j,k,ic,jc,kc,nsteps,n_pml; float ddx,dt,T,epsz,muz,pi,eaf,npml; int ib,jb,kb; . . . . ic=IE*0.5 ; jc=JE*0.5 ; ....'ic'dose not name a type. ....'jc'dose not name a type.

    Read the article

  • JAVA: 500 Worker Threads, what kind of thread pool?

    - by Submerged
    I am wondering if this is the best way to do this. I have about 500 threads that run indefinitely, but Thread.sleep for a minute when done one cycle of processing. ExecutorService es = Executors.newFixedThreadPool(list.size()+1); for (int i = 0; i < list.size(); i++) { es.execute(coreAppVector.elementAt(i)); //coreAppVector is a vector of extends thread objects } I do need a separate threads for each running task, so changing the architecture isn't an option. I tried making my threadPool size equal to Runtime.getRuntime().availableProcessors() which attempted to run all 500 threads, but only let 8 (4xhyperthreading) of them execute. The other threads wouldn't surrender and let other threads have their turn. I tried putting in a wait() and notify(), but still no luck. If anyone has a simple example or some tips, I would be grateful!

    Read the article

  • MATLAB: draw centroids

    - by Myx
    Hello - my main question is given a feature centroid, how can I draw it in MATLAB? In more detail, I have an NxNx3 image (an rgb image) of which I take 4x4 blocks and compute a 6-dimensional feature vector for each block. I store these feature vectors in an Mx6 matrix on which I run kmeans function and obtain the centroids in a kx6 matrix, where k is the number of clusters and 6 is the number of features for each block. How can I draw these center clusters in my image in order to visualize if the algorithm is performing the way I wish it to perform? Or if anyone has any other way/suggestions on how I can visualize the centroids on my image, I'd greatly appreciate it. Thank you.

    Read the article

  • O'Reilly book clarification on 2d linear system

    - by Eric
    The Oreilly book "Learning openCV" states at page 356 : Quote Before we get totally lost, let’s consider a particular realistic situation of taking measurements on a car driving in a parking lot. We might imagine that the state of the car could be summarized by two position variables, x and y, and two velocities, vx and vy. These four variables would be the elements of the state vector xk. Th is suggests that the correct form for F is: x = [ x; y; vx; vy; ]k F = [ 1, 0, dt, 0; 0, 1, 0, dt; 0, 0, 1, 0; 0, 0, 0, 1; ] It seems natural to put 'dt' just there in the F matrix but I just don't get why. What if I have a n states system, how would I spray some "dt" in the F matrix?

    Read the article

  • C++ Code Clarification Needed..

    - by ke3pup
    Hi guys I'm trying to understand what the code below says: struct compare_pq; struct compare_pq { bool operator() (Events *& a, Events *& b); }; std::priority_queue<Events *, std::vector<Events *>, compare_pq> eventList; i looked at what priority_queue is and how its declared but can't quit understand what compare_pq is doing in the priority_queue eventList. Also what does operator() do since i've never seen *& before and empty operator overloading operator()! any help would be appreciated. Thank you

    Read the article

  • ingenious idea needed: how to declare different sizes for different fonts? @font-face?

    - by Haroldo
    I've never seen this done, but i get a feeling that there's gotta be a clever way of doing it. css font-size-adjust looks like it was never meant to be, but when i look around I'm seeing some really ingenious css techniques going on. Take this on nettuts yesterday for using @font-face for vector icons. my challenge: if(user has calibri ) { font-family: calibri; font-size: 12px; } if(user hasn't calibri ) { font-family: arial; font-size: 10px; }

    Read the article

  • OpenLayers: Get resolution of map in a given projection (4326)

    - by David Pfeffer
    I'm using OpenLayers to display OpenStreetMap maps. (Though, I'd assume this should be general enough to work for any map product...) I'm displaying some very sophisticated vector overlays, and the amount and resolution of the features I'm returning from the server via GeoJSON to overlay has proven too much for many computers. What I'd like to do now instead is to only send data befitting the resolution of the current zoom. This should be relatively easy to do using the getResolution and calculateBounds methods on the Map object. calculateBounds returns a Bounds object that then can be transformed between the map projection and display projection. How do I transform the resolution into my desired projection (4326 in this case)?

    Read the article

  • Mono Ignores Graphics.InterpolationMode?

    - by Timothy Baldridge
    I have a program that draws some vector graphics using System.Drawing and the Graphics class. The anti-aliasing works, kindof okay, but for my need I neede oversampling, so I create the starting image to be n times larger and then scale back the final image by n. On Window and .NET the resulting image looks great! However, on Mono 2.4.2.3 (Ubuntu 9.10 stock install), the intropolation is horrible. Here's how I'm scaling my images: Bitmap bmp = new Bitmap(Bmp.Width / OverSampling, Bmp.Height / OverSampling); Graphics g = Graphics.FromImage(bmp); g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.DrawImage(Bmp, 0, 0, bmp.Width, bmp.Height); g.Dispose(); From what I can tell there is no interpolation happening at all. Any ideas?

    Read the article

  • the problem only happens when i try create a release...

    - by ace
    I'm sorry if im not presenting this right, but i trully cannot understand what the problem is. i have a project to hand in, a code of 600 lines defined within a main, .cpp, and header file. if i compile the project with just a debugger and no release, it's fine. when i create it with the release, the following error occurs, for every function!!! 1st error: |36|multiple definition of `countLines(int&, std::vector const&)'| 2nd error: |36|first defined here| if someone will allow me and i can send them the entire code, that would be awesome - i have to have this done within 3 hours.

    Read the article

  • List of functions references

    - by Ockonal
    Hello, I'm using boost::function for making references to the functions. Can I make a list of references? For example: boost::function<bool (Entity &handle)> behaviorRef; And I need in a list of such pointers. For example: std::vector<behaviorRef> listPointers; Of course it's wrong code due to behaviorRef isn't a type. So the question is: how can I store a list of pointers for the function?

    Read the article

  • Container for database-like searches

    - by Milan Babuškov
    I'm looking for some STL, boost, or similar container to use the same way indexes are used in databases to search for record using a query like this: select * from table1 where field1 starting with 'X'; or select * from table1 where field1 like 'X%'; I thought about using std::map, but I cannot because I need to search for fields that "start with" some text, and not those that are "equal to". I could create a sorted vector or list and use binary search (breaking the set in 2 in each step by reading the element in the middle and seeing if it's more or less than 'X'), but I wonder if there is some ready-made container I could use without reinventing the wheel?

    Read the article

  • Interpreter in C++: Function table storage problem

    - by sub
    In my interpreter I have built-in functions available in the language like print exit input, etc. These functions can obviously be accessed from inside the language. The interpreter then looks for the corresponding function with the right name in a vector and calls it via a pointer stored with its name. So I gather all these functions in files like io.cpp, string.cpp, arithmetic.cpp. But I have to add every function to the function list in the interpreter in order for it to be found. So in these function files I have things like: void print( arg ) { cout << arg.ToString; } I'd add this print function to the interpreter function list with: interpreter.AddFunc( "print", print ); But where should I call the interpreter.AddFunc? I can't just put it there below the print function as it has to be in a function according to the C++ syntax. Where and how should all the functions be added to the list?

    Read the article

  • C++ boost ublas + units dimension constraints

    - by aaa
    hello. I am seeking advice on design/general idea on how to force matrix dimension constraints on ublas matrix/vector possibly using boost units. For example, let matrix A have dimensions of time x force (for example) // does not have dimensions, time x force and force x time are not distinguished. matrix<double> A; //something like? dimension<time, force, matrix<double> > A; dimension<force, time, matrix<double> > B = trans(A); have you done something like this or do you have some good idea about how to organize such constraints? Thank you

    Read the article

  • Problem overridding virtual function

    - by William
    Okay, I'm writing a game that has a vector of a pairent class (enemy) that s going to be filled with children classes (goomba, koopa, boss1) and I need to make it so when I call update it calls the childclasses respective update. I have managed to create a example of my problem. #include <stdio.h> class A{ public: virtual void print(){printf("Hello from A");} }; class B : public A{ public: void print(){printf("Hello from B");} }; int main(){ A ab = B(); ab.print(); while(true){} } Output wanted: "Hello from B" Output got: "Hello from A" How do I get it to call B's print function?

    Read the article

  • Sorting by key > 10 integer sequences. with thrust

    - by smilingbuddha
    I want to perform a sort_by_key where I have a single key-sequence and multiple value sequences. One usually performs this with sort_by_key( key, key + N, make_zip_iterator( make_tuple(x1 , x2 , ...) ) ) However I want to perform a sort with 10 sequences each of length N. Thrust does not support tuples of size = 10. So is there a way around this ? Of course one can keep a separate copy of the key vector and perform sorts on bunches of 10 sequences. But I would like to do everything in a single call.

    Read the article

  • extraneous calls to copy-constructor and destructor

    - by eSKay
    [This question is a follow up to this question] class A { public: A() {cout<<"A Construction" <<endl;} A(A const& a){cout<<"A Copy Construction"<<endl;} ~A() {cout<<"A Destruction" <<endl;} }; int main() { { vector<A> t; t.push_back(A()); t.push_back(A()); // once more } } The output is: A Construction // 1 A Copy Construction // 1 A Destruction // 1 A Construction // 2 A Copy Construction // 2 A Copy Construction // WHY THIS? A Destruction // 2 A Destruction // deleting element from t A Destruction // deleting element from t A Destruction // WHY THIS?

    Read the article

  • Fast, Vectorizable method of taking floating point number modulus of special primes?

    - by caffiend
    Is there a fast method for taking the modulus of a floating point number? With integers, there are tricks for Mersenne primes, so that its possible to calculate y = x MOD 2^31 without needing division. Can any similar tricks be applied for floating point numbers? Preferably, in a way that can be converted into vector/SIMD operations, or moved into GPGPU code. The primes I'm interested in would be 2^7 and 2^31, although if there are more efficient ones for floating point numbers, those would be welcome.

    Read the article

  • c++ library for endian-aware reading of raw file stream metadata?

    - by Kache4
    I've got raw data streams from image files, like: vector<char> rawData(fileSize); ifstream inFile("image.jpg"); inFile.read(&rawData[0]); I want to parse the headers of different image formats for height and width. Is there a portable library that can can read ints, longs, shorts, etc. from the buffer/stream, converting for endianess as specified? I'd like to be able to do something like: short x = rawData.readLeShort(offset); or long y = rawData.readBeLong(offset) An even better option would be a lightweight & portable image metadata library (without the extra weight of an image manipulation library) that can work on raw image data. I've found that Exif libraries out there don't support png and gif.

    Read the article

< Previous Page | 78 79 80 81 82 83 84 85 86 87 88 89  | Next Page >