Questions tagged [vector]

2

votes
0

answer
128

Views

How can I map raster and vector data together?

I want to map raster and vector data in R Data class(Africa)# SpatialPolygonsDataFrame class(Rift)#SpatialLinesDataFrame class(Data.SP)#SpatialPointsDataFrame class(An_Precip_subTest)#RasterLayer` Code I am trying to run tm_shape(Africa) + tm_raster(An_Precip_subTest)+ tm_shape(Data.SP) + tm_dots(...
2

votes
0

answer
83

Views

How to read Mahout negative classification results

I'm using Mahout 0.8, and after classification using NaiveBayes i get results: FileName Category Score 1000221 male -13059.636009313888 1000378369 female -6660.011396382251 10004522 male -20388.73959786186 How to Read this Score? I want to get accuracy fo...
Milos
1

votes
0

answer
22

Views

conditionally filling a vector in parallel

I'd like to write a multi-threaded version of the following code template std::vector collect(std::vector const&values, Cond const&cond, Func const&func) { std::vector result; for(auto const&val : values) if(cond(val)) result.emplace_back(func(val)); return result; } where the order of selected elem...
Walter
0

votes
0

answer
33

Views

Replacing Transforms with Absolute Positioning in SVGs

Given this SVG snippet: How can one replace the transform attributes on to actual coordinates? I've been trying to animate elements with CSS Transforms, but I don't want to define absolute transform coordinates in CSS, rather move elements relative to their original position.
jonasll
0

votes
0

answer
5

Views

How to append 60 time values to a list of 4 million concatenated longitude and latitude values?

I am trying to make a vector that is 244,466,460 long that is the longitude, latitude and time as one value e.g., -1556788_-2323088_558322882. I have extracted the longitude and latitudes from my NetCDF file and concatenated them into a variable concatLonLat, large character, 4,074,441 elements, e.g...
Ilona
4

votes
0

answer
116

Views

Set animation valueFrom valueTo programmatically in Android animated-vector

I created an animated-vector as below, and it is used to implement the curve morph animation from path1 to path2. I have other curve pathes like path3,path4, path5, and I need implement the morph animation from path1->path3, path1->path4, path2->path1, path2->path3..., there are lots of combination...
feiyun
0

votes
0

answer
17

Views

How to Import C++ vector data to Swift

I have a C++ function that gets called by Swift that I need to return a vector of UIIMage's std::vector. The only problem is I don't know how to retrieve the value of the vector. C++ file 1: // OpenCVWrapper.h #import @interface OpenCVWrapper : NSObject +(???) convert:(UIImage *) image; @end file...
Cristian
0

votes
0

answer
66

Views

Cannot print a vector to a text file in C++

I'm working on the following problem: I need to write a prgoram that reads an ASCII text file from the hard drive and allows the user to display and edit the contents of the file line-by-line. It must have the following features: It reads the file name from the standard output and opens the text fil...
Arcana
3

votes
0

answer
90

Views

Is there a catalogue of collection related design patterns in C++? [closed]

Since the broader usage of std::shared_ptr and std::unique_ptr to handle memory management came up, I often run into problems of their proper usage in collections like std::vector. I'm looking for a catalogue of design patterns oder common usages - especially for C++ due to the issue of memory manag...
Elrond1337
2

votes
0

answer
237

Views

Segmentation Faults, Double free or corruption with vectors and SDL

I am attempting to code a basic game engine in c++/SDL. But while testing my first class, I get memory errors: or Segmentation Faults, or double free or corruption. It always crashes in the same way, but than the different errors seem to occur at random. To demonstrate, compile my source code and e...
Yk Cheese
4

votes
0

answer
785

Views

Cannot load vector Drawable in bitmap in XML

This is my first code that loads a Vector-Drawable in layer-list. it works fine.Later I had to change color of my vector drawable. I find that I should add bitmap to use tint attribute. This is my first code and vector drawable show fine in layer-list. // this is vector drawable so I changed my code...
Kenji
5

votes
0

answer
179

Views

Display a WFS service with OpenLayers 3. Define and add custom projection

I have a very simple question which I can not really find answers to. I am working with OpenLayers 3. I want to display a WFS Service with a layer defined in GeoServer 2.6.2. This layer is defined with a custom reference system which I have defined previously in GeoServer. I show you this SRS: +proj...
César
2

votes
0

answer
193

Views

What is the purpose of Vector3.Clamp?

Both the XNA Vector3 structure and the newer System.Numerics Vector3 provide a Clamp() method to 'clamp' a vector between two other vectors. ...What does that even mean? What practical purpose does this have?
2

votes
0

answer
79

Views

Auto-Vectorize max function, using Visual 2012

I'm currently trying to run a simple 'max function' loop scan on a large array of uint_32 values. Using AVX2 intrinsic, it's rather straightforward : const __m256i limit8 = _mm256_set1_epi32(limit); for (i=0; i
Cyan
0

votes
0

answer
22

Views

Why I cannot use reference type as the element of std::vector [duplicate]

This question already has an answer here: Why can't I make a vector of references? 8 answers Not sure why the reference type cannot be the type of element in std::vector. Following code won't compile: class Person { public: int m_id = 0; Person(int id) : m_id(id) { } }; std::vector personList; Anyo...
xpingc
4

votes
0

answer
75

Views

R my S4 vector won't index correctly in data.table

I'm trying to treat my own S4 class as a vector in a data.table. Everything works smoothly, except that when I index rows in the data.table, my indexing method is not applied to the vector. This works perfectly with a data.frame, but not a data.table. Here is my class: setClass('myvector', contains...
user3474009
2

votes
0

answer
46

Views

template static member vector of template structs (C++)

I think this code will explain itself better than I can with english: namespace SC { struct GraphicalDatumBase { struct SwitcherBase { virtual void switchBuffers(){} }; static std::vector switchers; static void switchBuffers(); virtual void update(){} }; template struct GraphicalDatum: public Graphi...
Byron
2

votes
0

answer
58

Views

I am having trouble adding elements to a referenced vector of a map

EDIT: Forgot to mention that my programming language is C++, and my IDE is Qt Creator. I don't understand why I am having trouble adding elements to a referenced vector of a map (i.e. sometimes it works and sometimes it fails). For example: class C_html4_tags { public: C_html4_tags(); //....... type...
Jammanuser
2

votes
0

answer
385

Views

direction vector between two geolocations

I'm building an Android AR-App (yes, another one), but I'm more interested in understanding the math behind it than using frameworks (knowing this and this). Given to locations (lat1,long1) and (lat2,long2) I'm searching for the direction vector (x,y,z) from Location1 to Location2. Using this Site...
Hackbard_C
3

votes
0

answer
1k

Views

Resizing / scale a vector-PDF on a webserver via PHP et cetera

I would like to solve the following task: I want to scale a PDF-file in a server-environment (PHP, Perl, ImageMagick, FPDF, etc.). The file consists of vector sprites and needs to be scaled non-linearely (X= AA %; Y = BB% of the original size). I would like to use something like Image Magick for it,...
Martin
2

votes
0

answer
92

Views

Handling gc of vector members correctly using SWIG wrappers for C++ with python

We are using SWIG to wrap our classes in C++ and use them in Python. What we have is a method in C++ which returns a vector containing objects of our custom class, say Foo. So basically, we have wrapped the following method using SWIG: std::vector my_cpp_method(char *); In the SWIG .i file, we have...
user3334059
2

votes
0

answer
71

Views

R for simulating random variable with zero correlation with other variables

I am trying to generate random data (using R programming) for variables e1,e2,e3 which should have zero correlation with random variable R. Variables e should have zero correlation with each other. The code written for generating variable e with zero correlation with R as follows: R
Hussein
2

votes
0

answer
52

Views

RE2 Cleanup Vector

as the title says I'm here with a 'little' problem regarding re2 regex and arrays. I need to load a lot of regex to test them with some strings. So I'm filling a vector. Here the first problem occurs: It it not possible to save re2::RE' Objects std::vector Regex; // gives error, copy constructor or...
kylecorver
2

votes
0

answer
234

Views

Pass vector<vector<float> > from C++ to Python

I am calling a Python module from C++ module. In my C++ module I have a vector data(size) Now, i want to pass this to python where I will be doing some manipulations onto it. I see that the command PyFloat_FromDouble returns a PyObject and converts double to float. Now, I want my data to be in float...
Sajal Jain
2

votes
0

answer
343

Views

std::valarray, std:vector or arma::vec?

I am not sure if this is the place for this question, but here it goes. I am working on computational physics model in C++ and I received a big code that I am tiding up. The field is quantum electronics, so there are lots of integrals and expressions, but my question concerns the optimization. Initi...
2

votes
0

answer
48

Views

Order stability problems in vector function

I am trying to write a function that quantifies numeric input by order of magnitude, using SI prefixes and an optional suffix. For example: 1 => 1 23.4 => 23.4 1001 => 1.0k 12345678 => 12.3MB (i.e., 'B' is the suffix) My first attempt mostly works: format.quantified format.quantified...
Xophmeister
2

votes
0

answer
75

Views

GLSL Perlin Noise with vec2 randomisation

I'm trying to implement Perlin Noise in GLSL using the following algorithm: Divide screen into chekerbord Compute pseudo-random vector (with some hash function) for each corner of each box of the checkerboard Compute the difference vectors from each corner of a box to the actual point Do the dot pro...
user7796115
2

votes
0

answer
245

Views

fasttext - Extracting and comparing pre-trained word vectors

I'm working with the German pre-trained word vectors from https://github.com/facebookresearch/fastText/blob/master/pretrained-vectors.md I encountered the following problems: To extract the vectors for my words, I started by simply searching the wiki.de.vec text-file for the respective words. Howeve...
Phil K
3

votes
0

answer
150

Views

How to reinitialize a struct in C without specifying it's type?

I'm trying to implement type-generic vector operations through C macros. My current implementation works if initialization and declaration happens on the same line, since the macro is then aware of the type of the vector: vec2_t(char) char_vector = vec2(10, 20); // unexpanded struct {char x,...
PandaConda
2

votes
0

answer
69

Views

Efficiently create graph structure from many 100d vectors in Python

I have millions of real-valued vectors. The dimension of the vectors is 100. I'd like to generate graph structure with given threshold that determines whether two vectors are connected or not. If threshold is 3, pair of vectors [(2,0,0,0...), (0,0,0,...)] are connected each other, and [(4,0,0,0,...)...
rkjt50r983
3

votes
0

answer
177

Views

Make wkhtmltopdf to render text instead of curves

When converting html into a PDF with wkhtmltopdf it seems that the text gets rendered to curves with the default options instead of getting a text-based PDF. As a consequence it's not possible to select the text in the PDF (as it is a bunch of curves ressembling text) as well as having rendering pro...
Xavi Montero
5

votes
0

answer
98

Views

Use `.at()` instead of operator `[]` for std::vector in debug mode [duplicate]

This question already has an answer here: How to make std::vector's operator[] compile doing bounds checking in DEBUG but not in RELEASE 5 answers Automatically check bounds in std::vector [duplicate] 4 answers Compile time triggered range check for std::vector 2 answers If I try to access an std...
schorsch312
0

votes
0

answer
12

Views

Undefined reference when passing 2d vector to a function

I'm writing a c++ program and I want to pass 2D vector to a function for modification, but I get undefined reference when I try to call this function. Now, I know what this error means. What I don't understand is what's further, because my compiler tries to call function with 3D vector? Where is err...
Wylfryd
2

votes
0

answer
273

Views

Reading single lines from file into vector

I have an input file of the following format: # 1 2 3 4 5 6 7 0 0 0 1 1 0 0 1 2 0 0 1 3 0 0 1 5 0 0 1 6 0 0 1 # 0 0 2 2 4 4 5 0 0 0 1 0 1 0 1 0 2 0 1 0 3 0 1 # 9 10 11 12 13 14 15 16 17 18 0 0 0 1 0 0 1 1 0 0 2 1 0 0 3 1 Each line preceded by a # must be read into its own vector. The entries in betw...
2

votes
0

answer
599

Views

How to Stop Android Tablet from Remapping Device Axes

I have a very specific problem. For Android devices whose default orientation is portrait (most phones), the device's axes are oriented like so: So, when trying to use vector and matrix math and I need to find the right, up, and out vectors for the device, I can use the following, which works perfe...
Dasmowenator
2

votes
0

answer
108

Views

vector() vs vector(0) unexplained runtime difference

Version 1 (1572.38ms): #include #include #include int main(int argc, char* argv[]) { std::chrono::time_point startTime = std::chrono::steady_clock::now(); int n = 1000000; int m = 1000; for (int k = 0; k < m; k++) { std::vector array(0); array.reserve(n); for (int i = 0; i < n - 10; i++) { array....
Damjan Dakic
2

votes
0

answer
173

Views

Wrapping standard library templates for DLL export (need sanity check)

I think I have a pretty good hold on the issues (different implementations, compiled binary differences, etc..) with exporting templates (vector, string, map, etc..) from the std library for a DLL (or lib) . However I find that I also dislike the use of custom vector/list/map classes and find creati...
Krazer
2

votes
0

answer
79

Views

3D to 2D - moving camera

I'm trying to make a 3D engine to to see how it works (i love to know how things exactly work) .. I heard that they put the camera somewhere and move and rotate the whole world - that was easy to make the only hard thing was making a function to multiply matrices but i want to move the camera and ke...
Hunar
2

votes
0

answer
194

Views

Can't use keyword arguments with overloaded functions

Note: The corresponding gist is here I'm SWIGging some C++ code to be used from Python, and I'm using std::vector in the interface, e.g., myfoo.hpp #ifndef MYFOO_HPP #define MYFOO_HPP #include double sum(const std::vector & a) { double sum = 0.0; for (const auto & elem: a) { sum += elem; } return s...
Nico Schlömer
2

votes
0

answer
79

Views

Scaling and dragging vector graphics in Android

I would like to be able to incorporate hand gestures to several hundred to thousand dynamically generated polygons so that I can pinch to zoom and drag all of them (not individually) simultaneously in Android. What is the best way to achieve that? Obviously, if there is a library that would be great...
Naci