Questions tagged [vector]

12250 questions
1

votes
1

answer
452

Views

Access element of a vector in a Spark DataFrame [closed]

I want to access the vector elements in the spark dataframe shown below:- name_cv (262144,[88783,143375,220659,228248],[1.0,1.0,1.0,1.0]) (262144,[220659],[1.0]) (262144,[75742],[1.0]) (262144,[68369,95745,107911,224494],[1.0,1.0,1.0,1.0]) & so on I want to to access 88783,143375,220659,228248 and a...
1

votes
1

answer
116

Views

Scala - Update mutable maps inside immutable Vector

I'm trying to build a Vector[Map[String, Any]] in Scala. I know that Vector is immutable, and I'm using mutable Map. When I try to do this: def calculate_objectives(pop: Vector[Map[String, Any]]): Unit ={ for (i decode(pop(i)('genome').asInstanceOf[Vector[Int]])) pop(i) = pop(i) + ('objective' -> V...
flyist
1

votes
0

answer
88

Views

'x' must be atomic for 'sort.list', using dbFD(). FD package

I am trying to run dbFD(traits, as.matrix(abun)) but i receive this error: Error in sort.list(y) : 'x' must be atomic for 'sort.list' Have you called 'sort' on a list? my data looks similar, but larger to this: t1 t2 t3 ... sp1 sp2 sp3 sp4.... sp1 0.2 10...
-1

votes
2

answer
38

Views

Can we use vector in c++ to take user input of unknown size only till we hit enter?

I was trying to take user input in a vector in c++, as vector is a dynamic data structure i wanted it to take input as long as user wants and when the user hit enter key it should stop taking the input (just as a string) only difference i want to do it in an integer vector, but i am unable to do so...
Agraj Singh
-1

votes
1

answer
16

Views

Error in multiplying matrix vector - invalid operands to binary * (have 'double *' and 'double *')

I'm trying to multiply a large and random matrix (NxN) and a random vector (N), using pointers. Why am i getting an error type 'invalid operands to binary * (have 'double *' and 'double *')' ? The error seems to be in ptr3[i][j] = ptr3[i] + ptr1[i] * ptr2[k]; but I can't figure out why this doesn...
Ana Fal
1

votes
1

answer
22

Views

Vector definition with varying length

I'm trying to figure out how to write a vector command allowing for variable length. Suppose that I have variables Item1 to Item7. I can write a vector statement... VECTOR Item = Item1 to Item7. In another situation I have 20 items instead of 7 (i.e., Item1 to Item20), and suppose I have a variable...
jclarke99
1

votes
0

answer
218

Views

Using C# System..Numerics.Vector<T> to unpack / pack bits

I’m testing the capabilities of the .Net C# System.Numerics.Vector class for packing and unpacking bits. I was hoping for Vector bitwise shift left/right functionality but that is not currently available so I tried to simulate shifting using arithmetic & logical methods as below. Here’s what I s...
Peter
1

votes
1

answer
50

Views

Raytracer reflections inconsistent

I'm writing a simple raytracer in Python, however I'm having trouble adding reflections to spheres. My code works fine for planes leading me to believe I'm calculating sphere normals incorrectly. I also noticed that reflections are not the same when viewed from different angles so I added a video ou...
1

votes
1

answer
139

Views

std::vector using back(), pop_back(), push_back(), get 'double free or corruption' error

I have the following code: struct branchInfo{ Quaternion r; Vector3 p; std::vector branchPoints; }; std::vector LSystem::Turtle(){ std::vector b; // The axiom should always start with a '[' at the start and a ']' at the end for(unsigned int i = 0; i < axiom.length(); i++) { char c = axiom[i]; if (c...
JustHeavy
1

votes
1

answer
75

Views

Project vector w onto vector v and draw perpendicular line - preparation for PCA

I want to do vector projection as preparation for PCA where I followed This tutorial for the calculation of the vector projection. w is the vector which 'points' onto the data points, v is the vector which spans the line onto which w should be projected. The code is: import numpy as np import matp...
2Obe
1

votes
2

answer
103

Views

Using 'new' in a template class is type safe?

I'm working on my own vector implementation, and one of the guys said on IRC, using 'new' to allocate memory in a template class isn't type safe. For example in this code: // resize array when needed template void myVector::resize() { vCapacity += 5; T* temp = new T[vCapacity](); for (unsigned i =...
enkeyz
1

votes
0

answer
52

Views

Array of vector

I am using an array of vectors. I have to count number of rows in the array. I am using the technique used for a 2D array. But it does not give desired output. int main() { int i,p=7; vector *mat=new vector[p]; int k=5; for(i=0;i
Rangerix
1

votes
1

answer
44

Views

How can I use iterator to pass the value in a recursive function in c++?

If I run the code as below then it crashes for the inputs. But if I do not use the iterator and use the code written in the comment section(in DFS() function) then it gets run well and doesn't crash anymore. I can't understand why this code is getting crashes by iterator. #include #include #include...
rosudel
1

votes
0

answer
35

Views

Print value from data frame, not rownumber

I have a simple data frame without row names (so row number is created automatically) and just one named Column ('sec'). And I want to get the value inside the cell 1:1. The attributes are the following: $`names` [1] 'sec' $row.names [1] 1 $class [1] 'data.frame' When I run: secCluster[1,1] I'am ge...
marius bäsler
1

votes
1

answer
253

Views

Quickest way to mask raster using polygons from gml file

I am building a headless script to preprocess Sentinel images. For info the session is setup as follows: import sys import os import qgis from qgis.core import * #from PyQt4.QtGui import * QgsApplication.setPrefixPath('/usr', False) app = QgsApplication([], False) app.initQgis() sys.path.append('/us...
ciskoh
1

votes
2

answer
65

Views

Data vectorization (get_dummies 3 columns to matrix)

I have a task, which must be optimally solved. I have 50 categories and 10,000 stores that can have products from these categories, but all this in 3 columns id_store category qnty 1 1 50 1 2 32 1 15 44 2 1 333 2 4 33 2...
Katrin
1

votes
1

answer
38

Views

Figure created from contour changes to be in raster format when the number of rows and columns larger than some threshold

A 2D data matrix (data, 100 rows by 100 cols) was plotted using 'contour' function in matlab, and the figure was saved as *.emf file. Expectedly when I insert the emf figure into MS word file, the figure is a vector graphic. But when I improve the resolution of the data, i.e. using imresize in matla...
emberbillow
2

votes
1

answer
21

Views

output a collection of collections using templated operator<<

I want to output a collection of collection (a vector of vectors in this case) by calling the outside collection once by operator
Shreyas Ragit
1

votes
0

answer
47

Views

R Atomic Vectors, how do access elements

I probably have a basic question, but this is the first time I've really gotten to grips with atomic vectors. I loaded data from a state file and placed into a data frame. Looks something like this: $ hv202 : atomic 13 13 43 13 13 13 13 13 42 21 ... ..- attr(*, 'label')= chr 'source of non-drinki...
1

votes
0

answer
33

Views
1

votes
0

answer
13

Views

Synchronizing ASC File Reading with Video Frames without having any common value

I have Vector ASC Log files and it's respective video files which are logged for same duration (lets say 5 minutes). Following is the Vector ASC File Format : . . . Video is getting logged in .avi format. While replaying I am loading both ASC file and it's respective video file. Problem is, how can...
Rish
1

votes
1

answer
29

Views

Creating a dataframe with vector entries

I am trying to create a pandas dataframe where the entry in a single cell is a numpy array. For example, given a list of chemical compounds - A2B3C4, D1A2J3 etc, I create a numpy array for each of them so that: firstium - A2B3C4 - [2,3,4,0,0,0,0.....] secondium - D1A2J3 - [2,0,0,1,......3....] I wou...
1

votes
1

answer
65

Views

Android drawable shape in xml

How I can create single vector xml drawable like this (black shape): To be able to use this in imageView and change it color
Volodymyr T
1

votes
0

answer
52

Views

R vector in network analysis

I am working on Network analysis in R. I am getting an error that says argument 2 is not a vector. Here is I have up until the error (the error is on the links = links line): library(igraph) nodes = read.csv('vertex.csv', header=T, as.is=T) links = read.csv('edges.csv', header=T, as.is=T) head(node...
Hosep
1

votes
1

answer
379

Views

Removing a pair from a vector of pairs [duplicate]

This question already has an answer here: How do I erase an element from std::vector by index? 10 answers I have a vector of pairs std::vector lambda; I would like to remove the kth element, i.e lambda.erase(&lambda[k]); lambda.erase(lambda[k]); Both of these attempts throws a no matching function...
HMPARTICLE
1

votes
0

answer
25

Views

About cgdsr R package

I installed cgdsr R package and I wanted to use a below function ranging from 0 to the end, which means I want to see all genes. But I don't know how to set c(1:?) that is a vector of gene names or a String specifying a single gene (required) for all genes. getProfileData(mycgds,c(1:100),mygeneticpr...
이춘경
1

votes
1

answer
27

Views
3

votes
0

answer
39

Views

operator< gives operator __surrogate_func error

I've implemented operator< for my c++ classes and when I tried it for a class that contains object vector; it fails and gives operator __surrogate_func When I remove object vector from class, everything is OK. I found this similar question about question but I dont know why Im getting this error? Be...
yunus celik
1

votes
0

answer
61

Views

Multiplication of RDD row to all other rows in PySpark

I have an RDD of DenseVector objects and I want to: Select one of these vectors (one row) Perform a multiplication of this vector to all other vector rows in order to compute a similarity (cosine) Basically I am trying to perform a dot product between a vector and a matrix, starting from an RDD. For...
mar tin
1

votes
1

answer
95

Views
1

votes
0

answer
70

Views

RAM consumption too high for vector allocation under R

I have difficulty under R with a problem, apparently quite common 'cannot allocate vector size XXX GB'. In my case there are two procedures, one with a failure on a vector of 1.1 GB and the other on a vector of 4.8 GB I work on following hardware resources : Windows 10 PC with an 8-core processor (X...
Thomas DUBOS
1

votes
1

answer
94

Views

Converting float vector to double

Im rather new to c++ so forgive my ignorance on this. Im trying to convert a double vector to a float vector for uses in certain cases( im aware there is a precision loss). The structure of the vectors is simply, struct Dvector { public: double X; double Y; double Z; Is there a simple function to cr...
Rareden
1

votes
1

answer
869

Views

React Native Custom Icons w/ Vector Icons

I'm new to React Native and I'm trying to have icons that are able to have their color changed based on json data received. I've been able to use React Native Vector Icons. However, I have my own icons that I would like to use. On the linked repo page there is something that talks about generating y...
pianoman102
1

votes
0

answer
13

Views

create a lineal-log-log-lineal partition of interval [a,b] in matlab, but matching steps

i want to create a vector x from a to b, in the following way. I have an interest point c , a
kurokirasama
1

votes
0

answer
18

Views

Make only specific path stretchable for vectors

This is the original vector: This what normally happen if you stretch a vector along x-axis: This is what I want to achieve: I know that I can achieve this by making custom view class or creating separate views. But I want to know if there is any way to achieve this using only resource file somethin...
AhmadF
1

votes
1

answer
46

Views

C++ Vector understanding

I am currently using codewars.com to practice my coding skills. I finished one of the problems and wanted to check what other people's solutions were and I found one I couldn't understand. It's much better than my solution and I would like to understand it more. such what does '*std' do exactly. wha...
Dead Pool
1

votes
1

answer
52

Views

C++: Queue of custom data type vector error

I am using a thread-safe queue of custom type vector. it shows the following error. I am not sure what I am missing here. Error C2664 'std::vector>::vector(std::vector &&,const _Alloc &) noexcept()': cannot convert argument 2 from 'int' to 'const std::allocator &'. #include #include #include #...
Zeeshan Hayat
1

votes
1

answer
302

Views

Icons not loading correctly react-native-vector-icons

I am using React-Native to build an application. I went on FlatIcon to get some custom icons, which I uploaded to IcoMoon and followed the installation steps to properly implement them on react-native. The problem is the result I am getting is completely different to what I installed. This the Icon...
SGhaleb
1

votes
0

answer
38

Views

Vector of vector re-size

So I have two vector of vectors like: matchings_vec = Vector{Vector{Vector{Vector{Any}}}}(num_tilt1) Minfoall_vec = Vector{Vector{Vector{Vector{Vector{Vector{Float64}}}}}}(num_tilt1) I defined it as: matchings_vec = [Vector{Any}() for i in 1:num_tilt1] Minfoall_vec = [Vector{Float64}() for i in 1:nu...
Isai
1

votes
0

answer
39

Views

How to create rounded corner rectangle shape using gradient and vector

Hello everyone I have to create background rounded corner rectangle of layout just like shown in attached image. I mentioned it in image by black box and arrow in image. Please suggest me what I can use for it gradient or vector and how can we create.
hharry_tech

View additional questions