Search Results

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

Page 46/103 | < Previous Page | 42 43 44 45 46 47 48 49 50 51 52 53  | Next Page >

  • Scipy Negative Distance? What?

    - by disappearedng
    I have a input file which are all floating point numbers to 4 decimal place. i.e. 13359 0.0000 0.0000 0.0001 0.0001 0.0002` 0.0003 0.0007 ... (the first is the id). My class uses the loadVectorsFromFile method which multiplies it by 10000 and then int() these numbers. On top of that, I also loop through each vector to ensure that there are no negative values inside. However, when I perform _hclustering, I am continually seeing the error, "Linkage Z contains negative values". I seriously think this is a bug because: I checked my values, the values are no where small enough or big enough to approach the limits of the floating point numbers and the formula that I used to derive the values in the file uses absolute value (my input is DEFINITELY right). Can someone enligten me as to why I am seeing this weird error? What is going on that is causing this negative distance error? ===== def loadVectorsFromFile(self, limit, loc, assertAllPositive=True, inflate=True): """Inflate to prevent "negative" distance, we use 4 decimal points, so *10000 """ vectors = {} self.winfo("Each vector is set to have %d limit in length" % limit) with open( loc ) as inf: for line in filter(None, inf.read().split('\n')): l = line.split('\t') if limit: scores = map(float, l[1:limit+1]) else: scores = map(float, l[1:]) if inflate: vectors[ l[0]] = map( lambda x: int(x*10000), scores) #int might save space else: vectors[ l[0]] = scores if assertAllPositive: #Assert that it has no negative value for dirID, l in vectors.iteritems(): if reduce(operator.or_, map( lambda x: x < 0, l)): self.werror( "Vector %s has negative values!" % dirID) return vectors def main( self, inputDir, outputDir, limit=0, inFname="data.vectors.all", mappingFname='all.id.features.group.intermediate'): """ Loads vector from a file and start clustering INPUT vectors is { featureID: tfidfVector (list), } """ IDFeatureDic = loadIdFeatureGroupDicFromIntermediate( pjoin(self.configDir, mappingFname)) if not os.path.exists(outputDir): os.makedirs(outputDir) vectors = self.loadVectorsFromFile( limit, pjoin( inputDir, inFname)) for threshold in map( lambda x:float(x)/30, range(20,30)): clusters = self._hclustering(threshold, vectors) if clusters: outputLoc = pjoin(outputDir, "threshold.%s.result" % str(threshold)) with open(outputLoc, 'w') as outf: for clusterNo, cluster in clusters.iteritems(): outf.write('%s\n' % str(clusterNo)) for featureID in cluster: feature, group = IDFeatureDic[featureID] outline = "%s\t%s\n" % (feature, group) outf.write(outline.encode('utf-8')) outf.write("\n") else: continue def _hclustering(self, threshold, vectors): """function which you should call to vary the threshold vectors: { featureID: [ tfidf scores, tfidf score, .. ] """ clusters = defaultdict(list) if len(vectors) > 1: try: results = hierarchy.fclusterdata( vectors.values(), threshold, metric='cosine') except ValueError, e: self.werror("_hclustering: %s" % str(e)) return False for i, featureID in enumerate( vectors.keys()):

    Read the article

  • Socket server with multiple clients, sending messages to many clients without hurting liveliness

    - by Karl Johanson
    I have a small socket server, and I need to distribute various messages from client-to-client depending on different conditionals. However I think I have a small problem with livelyness in my current code, and is there anything wrong in my approach: public class CuClient extends Thread { Socket socket = null; ObjectOutputStream out; ObjectInputStream in; CuGroup group; public CuClient(Socket s, CuGroup g) { this.socket = s; this.group = g; out = new ObjectOutputStream(this.socket.getOutputStream()); out.flush(); in = new ObjectInputStream(this.socket.getInputStream()); } @Override public void run() { String cmd = ""; try { while (!cmd.equals("client shutdown")) { cmd = (String) in.readObject(); this.group.broadcastToGroup(this, cmd); } out.close(); in.close(); socket.close(); } catch (Exception e) { System.out.println(this.getName()); e.printStackTrace(); } } public void sendToClient(String msg) { try { this.out.writeObject(msg); this.out.flush(); } catch (IOException ex) { } } And my CuGroup: public class CuGroup { private Vector<CuClient> clients = new Vector<CuClient>(); public void addClient(CuClient c) { this.clients.add(c); } void broadcastToGroup(CuClient clientName, String cmd) { Iterator it = this.clients.iterator(); while (it.hasNext()) { CuClient cu = (CuClient)it.next(); cu.sendToClient(cmd); } } } And my main-class: public class SmallServer { public static final Vector<CuClient> clients = new Vector<CuClient>(10); public static boolean serverRunning = true; private ServerSocket serverSocket; private CuGroup group = new CuGroup(); public void body() { try { this.serverSocket = new ServerSocket(1337, 20); System.out.println("Waiting for clients\n"); do { Socket s = this.serverSocket.accept(); CuClient t = new CuClient(s,group); System.out.println("SERVER: " + s.getInetAddress() + " is connected!\n"); t.start(); } while (this.serverRunning); } catch (IOException ex) { ex.printStackTrace(); } } public static void main(String[] args) { System.out.println("Server"); SmallServer server = new SmallServer(); server.body(); } } Consider the example with many more groups, maybe a Collection of groups. If they all synchronize on a single Object, I don't think my server will be very fast. I there a pattern or something that can help my liveliness?

    Read the article

  • How to remove list of words from strings

    - by zeljko
    What I would like to do (in Clojure): For example, I have a vector of words that need to be removed: (def forbidden-words [":)" "the" "." "," " " ...many more...]) ... and a vector of strings: (def strings ["the movie list" "this.is.a.string" "haha :)" ...many more...]) So, each forbidden word should be removed from each string, and the result, in this case, would be: ["movie list" "thisisastring" "haha"]. How to do this ?

    Read the article

  • Obtaining projection matrix

    - by rita
    I have calibrated stereo images. I want to get a projection matrix using rotation matrix ,translation vector, radial vector and a camera matrix. How can get the projection matrix?

    Read the article

  • Counting FLOPS/GFLOPS in program - CUDA

    - by msx
    Already finished my application which multiplies CRS matrix and vector (SpMV) and the only thing to do now is to count FLOPS my application did. In my opinion it's really hard to estimate number of floating point operation in case of sparse matrix - vector multiplication, because the number of multiplies in one row is really "jumpy" or fluent. I only tried to measure time using "cudaprof" ( available in ./CUDA/bin directory) - it works fine. Any sugestions and instruction pastes appreciated !

    Read the article

  • BoundsChecker shows incorrect memory leak message

    - by Prabhu
    Hello All, I'm using BoundsChecker9.1 with visual c++. I have a class class Sample{ public: vector(AnotherClass) x; }. When I run my program the BoundsChecker tool reports all push_back() calls such as S.x.push_back(AnotherClass()) as memory leak.. Wouldn't all the elements in vector x will always be deallocated when the Sample class goes out of scope? If so, any idea about why BoundsChecker is showing them as memory leak?

    Read the article

  • Drawing N-width lines?

    - by user146780
    Given a series of points, how could I calculate the vector for that line 5 pixels away? Ex: Given: \ \ \ How could I find the vector for \ \ \ \ \ \ The ones on the right. But bear in mind that it may not always be a nice straight line. I'm trying to figure out how programs like Flash can make thick outlines. Thanks

    Read the article

  • Copy constructor, objects, pointers

    - by Pauff
    Let's say I have this: SolutionSet(const SolutionSet &solutionSet) { this->capacity_ = solutionSet.capacity_; this->solutionsList_ = solutionSet.solutionsList_; // <-- } And solutionsList_ is a vector<SomeType*> vect*. What is the correct way to copy that vector (I suppose that way I'm not doing it right..)?

    Read the article

  • Idiomatic use of auto_ptr to transfer ownership to a container

    - by heycam
    I'm refreshing my C++ knowledge after not having used it in anger for a number of years. In writing some code to implement some data structure for practice, I wanted to make sure that my code was exception safe. So I've tried to use std::auto_ptrs in what I think is an appropriate way. Simplifying somewhat, this is what I have: class Tree { public: ~Tree() { /* delete all Node*s in the tree */ } void insert(const string& to_insert); ... private: struct Node { ... vector<Node*> m_children; }; Node* m_root; }; template<T> void push_back(vector<T*>& v, auto_ptr<T> x) { v.push_back(x.get()); x.release(); } void Tree::insert(const string& to_insert) { Node* n = ...; // find where to insert the new node ... push_back(n->m_children, auto_ptr<Node>(new Node(to_insert)); ... } So I'm wrapping the function that would put the pointer into the container, vector::push_back, and relying on the by-value auto_ptr argument to ensure that the Node* is deleted if the vector resize fails. Is this an idiomatic use of auto_ptr to save a bit of boilerplate in my Tree::insert? Any improvements you can suggest? Otherwise I'd have to have something like: Node* n = ...; // find where to insert the new node auto_ptr<Node> new_node(new Node(to_insert)); n->m_children.push_back(new_node.get()); new_node.release(); which kind of clutters up what would have been a single line of code if I wasn't worrying about exception safety and a memory leak. (Actually I was wondering if I could post my whole code sample (about 300 lines) and ask people to critique it for idiomatic C++ usage in general, but I'm not sure whether that kind of question is appropriate on stackoverflow.)

    Read the article

  • WPF Reusing Xaml Effectively

    - by Steve
    Hi, I've recently been working on a project using WPF to produce a diagram. In this I must show text alongside symbols that illustrate information associated with the text. To draw the symbols I initially used some png images I had produced. Within my diagram these images appeared blurry and only looked worse when zoomed in on. To improve on this I decided I would use a vector rather than a rastor image format. Below is the method I used to get the rastor image from a file path: protected Image GetSymbolImage(string symbolPath, int symbolHeight) { Image symbol = new Image(); symbol.Height = symbolHeight; BitmapImage bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.UriSource = new Uri(symbolPath); bitmapImage.DecodePixelHeight = symbolHeight; bitmapImage.EndInit(); symbol.Source = bitmapImage; return symbol; } Unfortunately this does not recognise vector image formats. So instead I used a method like the following, where "path" is the file path to a vector image of the format .xaml: public static Canvas LoadXamlCanvas(string path) { //if a file exists at the specified path if (File.Exists(path)) { //store the text in the file string text = File.ReadAllText(path); //produce a canvas from the text StringReader stringReader = new StringReader(text); XmlReader xmlReader = XmlReader.Create(stringReader); Canvas c = (Canvas)XamlReader.Load(xmlReader); //return the canvas return c; } return null; } This worked but drastically killed performance when called repeatedly. I found the logic necessary for text to canvas conversion (see above) was the main cause of the performance problem therefore embedding the .xaml images would not alone resolve the performance issue. I tried using this method only on the initial load of my application and storing the resulting canvases in a dictionary that could later be accessed much quicker but I later realised when using the canvases within the dictionary I would have to make copies of them. All the logic I found online associated with making copies used a XamlWriter and XamlReader which would again just introduce a performance problem. The solution I used was to copy the contents of each .xaml image into its own user control and then make use of these user controls where appropriate. This means I now display vector graphics and performance is much better. However this solution to me seems pretty clumsy. I'm new to WPF and wonder if there is some built in way of storing and reusing xaml throughout an application? Apologies for the length of this question. I thought having a record of my attempts might help someone with any similar problem. Thanks.

    Read the article

  • C++ Undeclared Identifier (but it is declared?)

    - by Joshua
    I'm pretty sure I've included the qanda class, but when I try to declare a vector that contains it or a class of that type I get an error saying that qanda is undefined. Any idea what the problem might be? bot_manager_item.h #pragma once #include "../bot_packet/bot_packet.h" #include <vector> class bot_manager_item; #include "qanda.h" #include "bot_manager.h" class bot_manager_item { public: bot_manager_item(bot_manager* mngr, const char* name, const char* work_dir); ~bot_manager_item(); bool startup(); void cleanup(); void on_push_event(bot_exchange_format f); bool disable; private: void apply_changes(); bot_manager *_mngr; std::string _name; std::string _work_dir; std::string _message; std::string _message_copy; std::vector<qanda> games; qanda test; char _config_full_path[2600]; }; qanda.h #ifndef Q_AND_A #define Q_AND_A #include "users.h" #include "..\bot_packet\bot_packet.h" #include "bot_manager.h" #include <string> #include <algorithm> #include <map> #include <vector> #include <fstream> class qanda { public: qanda(bot_manager * manager, std::string name, std::string directory); ~qanda(){}; void room_message(std::string username, std::string user_message); void timer_tick(); private: // data members std::string question; std::string answer; std::string directory; std::string command_prefix; std::string name; Users users; std::map <std::string, std::string> questions_and_answers; int time_per_question; // seconds int time_between_questions; // seconds int timer; // milliseconds bool is_delayed; bool is_playing; bot_manager * manager; // functions void new_question(); void send_message(std::string msg); void announce_question(); void load_questions(); }; #endif

    Read the article

  • j2me bluetooth client. Function startInquiry nothing found.

    - by Hugi
    I develop simple j2me bluetooth client and have problem with bluetooth device search. Function startInquiry nothing found. Client : nokia 5220 Server : my pc with bluetooth adapter All bluetooth devices is on. /* * To change this template, choose Tools | Templates * and open the template in the editor. */ import javax.microedition.midlet.*; import javax.bluetooth.*; import java.util.Vector; import javax.microedition.lcdui.*; /** * @author ????????????? */ public class Midlet extends MIDlet implements DiscoveryListener { private static Vector vecDevices=new Vector(); private static String connectionURL=null; private LocalDevice localDevice; private DiscoveryAgent agent; private RemoteDevice remoteDevice; private RemoteDevice[] devList; private Display display; private Form form; public void startApp() { display = Display.getDisplay(this); form = new Form( "Client" ); try { localDevice = LocalDevice.getLocalDevice(); } catch( BluetoothStateException e ) { e.printStackTrace(); } form.append("Address: "+localDevice.getBluetoothAddress()+"\n\n"); form.append("Name: "+localDevice.getFriendlyName()+"\n\n"); try { agent = localDevice.getLocalDevice().getDiscoveryAgent(); form.append("Starting device inquiry... \n\n"); boolean si = agent.startInquiry(DiscoveryAgent.GIAC, this); if ( si ) { form.append("true"); } else { form.append("false"); } } catch( BluetoothStateException e ) { } int deviceCount = vecDevices.size(); if(deviceCount <= 0){ form.append("No Devices Found ."); } else{ //print bluetooth device addresses and names in the format [ No. address (name) ] form.append("Bluetooth Devices: "); for (int i = 0; i < deviceCount; i++) { remoteDevice=(RemoteDevice)vecDevices.elementAt(i); form.append( remoteDevice.getBluetoothAddress() ); } } display.setCurrent(form); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) { //add the device to the vector if(!vecDevices.contains(btDevice)){ vecDevices.addElement(btDevice); } } public void inquiryCompleted(int discType) { } //implement this method since services are not being discovered public void servicesDiscovered(int transID, ServiceRecord[] servRecord) { if(servRecord!=null && servRecord.length>0){ connectionURL=servRecord[0].getConnectionURL(0,false); } } //implement this method since services are not being discovered public void serviceSearchCompleted(int transID, int respCode) { } }

    Read the article

  • Why does std::map operator[] create an object if the key doesn't exist?

    - by n1ck
    Hi, I'm pretty sure I already saw this question somewhere (comp.lang.c++? Google doesn't seem to find it there either) but a quick search here doesn't seem to find it so here it is: Why does the std::map operator[] create an object if the key doesn't exist? I don't know but for me this seems counter-intuitive if you compare to most other operator[] (like std::vector) where if you use it you must be sure that the index exists. I'm wondering what's the rationale for implementing this behavior in std::map. Like I said wouldn't it be more intuitive to act more like an index in a vector and crash (well undefined behavior I guess) when accessed with an invalid key? Refining my question after seeing the answers: Ok so far I got a lot of answers saying basically it's cheap so why not or things similar. I totally agree with that but why not use a dedicated function for that (I think one of the comment said that in java there is no operator[] and the function is called put)? My point is why doesn't map operator[] work like a vector? If I use operator[] on an out of range index on a vector I wouldn't like it to insert an element even if it was cheap because that probably mean an error in my code. My point is why isn't it the same thing with map. I mean, for me, using operator[] on a map would mean: i know this key already exist (for whatever reason, i just inserted it, I have redundancy somewhere, whatever). I think it would be more intuitive that way. That said what are the advantage of doing the current behavior with operator[] (and only for that, I agree that a function with the current behavior should be there, just not operator[])? Maybe it give clearer code that way? I don't know. Another answer was that it already existed that way so why not keep it but then, probably when they (the ones before stl) choose to implement it that way they found it provided an advantage or something? So my question is basically: why choose to implement it that way, meaning a somewhat lack of consistency with other operator[]. What benefit do it give? Thanks

    Read the article

  • How do I send information to an HLSL effect in DirectX 10?

    - by pypmannetjies
    I'd like to send my view vector to an ID3D10Effect variable in order to calculate specular lighting. How do I send a vector or even just scalar values to the HLSL from the running DirectX program? I want to do something like render() { //do transformations D3DXMatrix view = camera->getViewMatrix(); basicEffect.setVariable(viewVector, view); //render stuff }

    Read the article

  • Projection on a plane using a 2*3 matrix

    - by leipäjuusto
    Hello, I can easily draw the projection of a 3D set of points onto the plane with normal vector (1,1,1), by using the matrix (-sqrt(3)/2 sqrt(3)/2 0) (-1/2 -1/2 1). I want to do the same thing, but for a projection onto an arbitrary plane with normal vector (a,b,c) instead of (1,1,1). How to find the matrix? Thanks in advance!

    Read the article

  • Logic error for Gauss elimination

    - by iwanttoprogram
    Logic error problem with the Gaussian Elimination code...This code was from my Numerical Methods text in 1990's. The code is typed in from the book- not producing correct output... Sample Run: SOLUTION OF SIMULTANEOUS LINEAR EQUATIONS USING GAUSSIAN ELIMINATION This program uses Gaussian Elimination to solve the system Ax = B, where A is the matrix of known coefficients, B is the vector of known constants and x is the column matrix of the unknowns. Number of equations: 3 Enter elements of matrix [A] A(1,1) = 0 A(1,2) = -6 A(1,3) = 9 A(2,1) = 7 A(2,2) = 0 A(2,3) = -5 A(3,1) = 5 A(3,2) = -8 A(3,3) = 6 Enter elements of [b] vector B(1) = -3 B(2) = 3 B(3) = -4 SOLUTION OF SIMULTANEOUS LINEAR EQUATIONS The solution is x(1) = 0.000000 x(2) = -1.#IND00 x(3) = -1.#IND00 Determinant = -1.#IND00 Press any key to continue . . . The code as copied from the text... //Modified Code from C Numerical Methods Text- June 2009 #include <stdio.h> #include <math.h> #define MAXSIZE 20 //function prototype int gauss (double a[][MAXSIZE], double b[], int n, double *det); int main(void) { double a[MAXSIZE][MAXSIZE], b[MAXSIZE], det; int i, j, n, retval; printf("\n \t SOLUTION OF SIMULTANEOUS LINEAR EQUATIONS"); printf("\n \t USING GAUSSIAN ELIMINATION \n"); printf("\n This program uses Gaussian Elimination to solve the"); printf("\n system Ax = B, where A is the matrix of known"); printf("\n coefficients, B is the vector of known constants"); printf("\n and x is the column matrix of the unknowns."); //get number of equations n = 0; while(n <= 0 || n > MAXSIZE) { printf("\n Number of equations: "); scanf ("%d", &n); } //read matrix A printf("\n Enter elements of matrix [A]\n"); for (i = 0; i < n; i++) for (j = 0; j < n; j++) { printf(" A(%d,%d) = ", i + 1, j + 1); scanf("%lf", &a[i][j]); } //read {B} vector printf("\n Enter elements of [b] vector\n"); for (i = 0; i < n; i++) { printf(" B(%d) = ", i + 1); scanf("%lf", &b[i]); } //call Gauss elimination function retval = gauss(a, b, n, &det); //print results if (retval == 0) { printf("\n\t SOLUTION OF SIMULTANEOUS LINEAR EQUATIONS\n"); printf("\n\t The solution is"); for (i = 0; i < n; i++) printf("\n \t x(%d) = %lf", i + 1, b[i]); printf("\n \t Determinant = %lf \n", det); } else printf("\n \t SINGULAR MATRIX \n"); return 0; } /* Solves the system of equations [A]{x} = {B} using */ /* the Gaussian elimination method with partial pivoting. */ /* Parameters: */ /* n - number of equations */ /* a[n][n] - coefficient matrix */ /* b[n] - right-hand side vector */ /* *det - determinant of [A] */ int gauss (double a[][MAXSIZE], double b[], int n, double *det) { double tol, temp, mult; int npivot, i, j, l, k, flag; //initialization *det = 1.0; tol = 1e-30; //initial tolerance value npivot = 0; //mult = 0; //forward elimination for (k = 0; k < n; k++) { //search for max coefficient in pivot row- a[k][k] pivot element for (i = k + 1; i < n; i++) { if (fabs(a[i][k]) > fabs(a[k][k])) { //interchange row with maxium element with pivot row npivot++; for (l = 0; l < n; l++) { temp = a[i][l]; a[i][l] = a[k][l]; a[k][l] = temp; } temp = b[i]; b[i] = b[k]; b[k] = temp; } } //test for singularity if (fabs(a[k][k]) < tol) { //matrix is singular- terminate flag = 1; return flag; } //compute determinant- the product of the pivot elements *det = *det * a[k][k]; //eliminate the coefficients of X(I) for (i = k; i < n; i++) { mult = a[i][k] / a[k][k]; b[i] = b[i] - b[k] * mult; //compute constants for (j = k; j < n; j++) //compute coefficients a[i][j] = a[i][j] - a[k][j] * mult; } } //adjust the sign of the determinant if(npivot % 2 == 1) *det = *det * (-1.0); //backsubstitution b[n] = b[n] / a[n][n]; for(i = n - 1; i > 1; i--) { for(j = n; j > i + 1; j--) b[i] = b[i] - a[i][j] * b[j]; b[i] = b[i] / a[i - 1][i]; } flag = 0; return flag; } The solution should be: 1.058824, 1.823529, 0.882353 with det as -102.000000 Any insight is appreciated...

    Read the article

  • Providing *implicit* conversion operator for template specialization

    - by Neil G
    I have a templated sparse_vector<T> class, and I am also using Boost UBLAS. How would I provide implicit conversions between sparse_vector<double> and boost::numeric::ublas::compressed_vector<double>? I would also like to provide similar conversions between std::vector<double> and boost::numeric::ublas::vector<double>. (I am using gcc 4.4 with C++0x enabled.)

    Read the article

  • Function templates for arbitrary STL containers containing arbitrary types.

    - by Chad Brewbaker
    I have an arbitrary STL container C, which contains elements of an arbitrary type T. I want to create an std::vector that has a copy of all the elements. What is the cleanest way to do this? template <typename C> void myfunction(C container){ /*Derive the type T of elements within the container*/ std::vector<T> mystack; /* Iterate over container and push_back() the elements into mystack*/ }

    Read the article

  • Does Boost work with IntervalZero RTX 2009?

    - by cs-79
    Hi all Rtx experts, Have anyone implemented hard real-time app on IntervalZero Rtx environment using Boost libraries? I wish to use the Boost `unordered` data structures instead of solely relying on STL::Vector. Or Array/Vector is the only data structure supported by Rtx? * Off topic question: Can we use STL::String instead of char pointer for string in Rtx? Thanks.

    Read the article

  • C++ stl collections or linked lists

    - by Lucas
    I'm developing a OpenGL based simulation in C++. I'm optmizing my code now and i see throughout the code the frequently use of std:list and std:vector. What is the more performatic: to continue using C++ stl data structs or a pointer based linked list? The main operation that involve std::list and std::vector is open a iterator and loop through all items in the data structs and apply some processing

    Read the article

  • What is wrong with this C++ Code ?

    - by mr.bio
    Hi .. i am a beginner and i have a problem : this code doesnt compile : main.cpp: #include <stdlib.h> #include "readdir.h" #include "mysql.h" #include "readimage.h" int main(int argc, char** argv) { if (argc>1){ readdir(argv[1]); // test(); return (EXIT_SUCCESS); } std::cout << "Bitte Pfad angeben !" << std::endl ; return (EXIT_FAILURE); } readimage.cpp #include <Magick++.h> #include <iostream> #include <vector> using namespace Magick; using namespace std; void readImage(std::vector<string> &filenames) { for (unsigned int i = 0; i < filenames.size(); ++i) { try { Image img("binary/" + filenames.at(i)); for (unsigned int y = 1; y < img.rows(); y++) { for (unsigned int x = 1; x < img.columns(); x++) { ColorRGB rgb(img.pixelColor(x, y)); // cout << "x: " << x << " y: " << y << " : " << rgb.red() << endl; } } cout << "done " << i << endl; } catch (Magick::Exception & error) { cerr << "Caught Magick++ exception: " << error.what() << endl; } } } readimage.h #ifndef _READIMAGE_H #define _READIMAGE_H #include <Magick++.h> #include <iostream> #include <vector> #include <string> using namespace Magick; using namespace std; void readImage(vector<string> &filenames) #endif /* _READIMAGE_H */ If want to compile it with this code : g++ main.cpp Magick++-config --cflags --cppflags --ldflags --libs readimage.cpp i get this error message : main.cpp:5: error: expected initializer before ‘int’ i have no clue , why ? :( Can somebody help me ? :)

    Read the article

  • Quaternion Cameras and projectile vectors

    - by Tom J Nowell
    In our software we have a camera based on mouse movement, and a quarternion at its heart. We want to fire projectiles from this position, which we can do, however we want to use the camera to aim. The projectile takes a vector which it will add to its position each game frame. How do we acquire such a vector from a given camera/quaternion?

    Read the article

< Previous Page | 42 43 44 45 46 47 48 49 50 51 52 53  | Next Page >