## How to create a database of feature vectors for images?

I have a database of around 4 classes each consistent of around 50 images. I created a features vector on Matlab to extract the features I need from each image. How to create the database of vectors for all the images to then train them per class? ...
more »

## Find the first set of consecutive integers in a vector

I have a dataset where I am trying to find the first instance in a consecutive set of rows that are identical. So let's say given this dataset: df <- data.frame(trial = c(1:16), DV = c(2, 3, 2, 3, 3, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 1)) If I were...
more »

## How to select a small part of very large vector in time?

I have a vector with a name stim. The length of the vector is len(stim)=600000. The vector stim has 600000 indices over time. The vector is given below. In [168]:stim Out[168]: array([-111.94824219, -81.80664062, 10.21972656, ..., 9.78515625...
more »

## generate random sequences of NA of random lengths in a vector

I want to generate missing values in a vector so that the missing value are grouped in sequences, to simulate periods of missing data of different length. Let's say I have a vector of 10 000 values and I want to generate 12 sequences of NA at random...
more »

## numpy: how to construct a matrix of vectors from vector of matrix

I'm new to numpy, so, with numpy, is it possible to use a vector of matrix to get a matrix of vectors" for example: matrix1( [ [1, 2, 3], [1, 2, 3], [1, 2, 3] ]) matrix2( [ [2, 4, 6], [2, 4, 6], [2, 4, 6] ]) --> matr...
more »

## Nested rolling sum in vector

I am struggling to produce an efficient code to compute the vector result r result from an input vector v using this function. r(i) = \sum_{j=i}^{i-N} [o(i)-o(j)] * exp(o(i)-o(j)) where i loops (from N to M) over the vector v. Size of v is M&...
more »

## How do I generate an IO Vector?

Data.Vector has generate :: Int -> (Int -> a) -> Vector a but I don't see an equivalent in Data.Vector.Mutable. What am I missing? ...
more »

## How can I return a vector from a function in c++?

vector<double> function(vector<double> &X){ vector<double> data2; for (int i = 0; i < X.size(); i++){ data2.push_back(2*X[i]); } return data2; } int main(){ vector<double> data; for (int ...
more »

## Constructor of user-defined class not working with vector

My problem is very simple, the constructor of a class is not working with a std::vector. class my_class { public: my_class() { std::cout << "my_class constructed\n"; } }; int main() { std::vector <my_class> v; } The program di...
more »

## Efficiently converting and writing a vector to a handle

I'm writing a program that performs a transformation on sample data in a file. I do this by reading the file, turning the content into a vector, performing the transformation on the vector and then writing the vector back to the file. I already (thin...
more »

## Replace initial NA values with zero in a row until non NA column

Consider the following row in a dataset:- #Row (initially): NA NA NA NA NA NA NA 2 3 1 4 5 2 NA NA 6 7 I want all such rows to be transformed into #Row (modified) : 0 0 0 0 0 0 0 2 3 1 4 5 2 NA NA 6 7 Only the initial NA that occur befo...
more »

## After combine the vectors into matrix, how to keep the original attribute of vector (not changed)

below R code show an example about vectors combination, after that, the attribute of vector "c" changed to character. how to make it still keep attribute as numeric? a='aa';b='bb';c=c(1,2,3,4,5) dd=data.table(cbind(a,b,c));dd;class(dd);class(a);clas...
more »

## How to nest unboxed vectors?

This may be a pretty basic question, but I've searched around and I cannot seem to find the answer. I would like to represent a 2D list using unboxed Vectors. This is easily done with normal vectors: > import qualified Data.Vector as V > V.fr...
more »

I think I'm still a little unclear on how R works on individual elements in vectorized statements. I have the following code df1$flag <- ifelse(df1$year < 2013 & df1$year == df2$year & as.character(df1$code) == as.char... more » 2017-05-19 17:05 (1) Answers ## Passing pointer of vector of objects as arguments but a lot more different This question does look like a copy and paste of an old one (which it sort of is) but I assure you the situation is a lot more different and very hard to explain so please hear me out before you murder my miniscule reputation. I am having issues wit... more » 2017-05-19 07:05 (1) Answers ## Do any functions in the R language besides "formula" parse functions form string Vectors? Due to the fact that "formula" takes a character vector with R functions included, it creates a security concern as explained in https://arxiv.org/pdf/1303.4808.pdf. Situations like this can occur: userformula <- "speed ~ dist + system('whoami... more » 2017-05-17 22:05 (0) Answers ## Strange error in c++ class construction I have recently started learning c++ and I am now trying to make a simple vector class as an exercise. But somehow my code doesn't seem to work. #include <iostream> #include <cmath> class Vec2 { public: float x1; float x2; Ve... more » 2017-05-17 11:05 (4) Answers ## Testing whether two vectors are increasing or decreasing in R I was wondering if there might be a way in base R to test whether two vectors (BOTH OF THEM) are increasing or decreasing? For example, the test should return FALSE when testing a and b (see below) and the test should return TRUEwhen testing c and ... more » 2017-05-17 06:05 (2) Answers ## How do I reorder testing data sets for a neural network in MATLAB? I have 300 images in a folder that I'm using as a data set for validation of a neural network. Each image has a label of 1 or 0. I converted the images to a matrix in MATLAB and the labels to a 300x1 vector of either 1 or 0 that corresponds to each... more » 2017-05-13 17:05 (1) Answers ## C++ Static vectors in classes I am working on a restraunt order system as a project for my computer science class and I was wondering if it would be best practice to use a static vector within my Order class to contain all of my orders or should I have it in my main program? I'm ... more » 2017-05-10 22:05 (1) Answers ## Vectorizing nearest neighbor computation I have the following function which is returning an array calculating the nearest neighbor: def p_batch(U,X,Y): return [nearest(u,X,Y) for u in U] I would like to replace the for loop using numpy. I've been looking into numpy.vectorize() as th... more » 2017-05-08 19:05 (1) Answers ## Can I trust vector::size after an exception is thrown? I am trying to understand how exceptions affect an std::vector. More precisely, I want to check the size of the vector, when an out of memory exception is thrown. I mean something like this: std::vector<int> v; try { for(unsigned int i = ... more » 2017-05-08 13:05 (2) Answers ## using prolog & clpr for a system of constraints I'm looking to use prolog in a desktop application to generate a random vector that satisfies a system of constraints. As an example, our user might provide our software with the following information at runtime: Given a vector <x1, x2, x3, ... ... more » 2017-05-08 09:05 (1) Answers ## Fill in empty values with the last non-empty in vector I would like to fill in the missing values (not NA, just ''!) in a vector with the value before it. For example, if I have a vector defined as vec <- c('Titanic', '', '', '', 'Donnie Darko', '', '', 'Twin Peaks', 'American Hustle', '') ... more » 2017-05-07 23:05 (4) Answers ## Calling member functions on const iterators I've got two classes, one Measurement class which contains a vector<double> and an Experiment which contains a vector<Measurement>: class Measurement { private: vector<double> dataSet; string time_stamp; public: con... more » 2017-05-07 20:05 (3) Answers ## Sorting 2d vector passed by reference I implemented Prim's algorithm. It returns a std::vector<std::vector<int>> (which is a vector of vectors : [vertice, vertice, weight]). The results are correct, but when I compare it with my lab guys results, sometimes there is a differen... more » 2017-05-07 19:05 (1) Answers ## How does one convert a data set with two labels +1 and -1 to a hot one vector representation in a vectorized way in Python? I have a data set in numpy with a x vector and a y vector. The y vectors is only two values +1 or -1 (or 0 or 1) because its a binary valued function. I know I can just loop over the data set and if I see a +1 to map it to 1 and if I see and -1 map i... more » 2017-05-07 01:05 (3) Answers ## How to create a vector between 2 dates in R I am new to R and I would like to create a vector between 2 dates a Here is my code start.plot <- c("2011-01-01", "2012-12-31") plot1 <- substr(start.plot[1],1,7) plot2 <- substr(start.plot[2],1,7) Month_test <- as.character(seq(as... more » 2017-05-05 16:05 (1) Answers ## Finding the average maximum pairing of two vector I have an integer variable res which stores the sum of of each element from one vector to another vector where the results are kept track. a <- 1:3 b <- 4:6 nm <- outer(seq_along(a), seq_along(b), FUN = function(x, y) sprintf('a%d + b%d', x... more » 2017-05-02 08:05 (1) Answers ## Why do$ and [ on a data frame column give different output presentation and data types?

I'm new to R. Just learning via online tutorials. My question is: 1) Why does accessing the same column with different syntaxes have different output presentation? Vertical Display: > airquality["Ozone"] Ozone 1 41 2 36 3 12...
more »

## Switch input for sorting algorithm

I wrote an insertion sort below: int i, j; Book temp; for (j = 1; j < books.size(); j++) { temp = books[j]; i = j - 1; while (i >= 0) { if (temp.getAuthor().compare(books[i].getAuthor()) > 0) { break; ...
more »

## Accessing methods of class object that it's in a vector

Ok so i have a class class person and i have a vector<person>group that saves different objects from the class person. Also the class person has the method void getName() that gets the name. My question is how can i search the vector so i can u...
more »

## R: Apply function to matrix with elements of vector as argument

Suppose I want to apply a function to each row of a matrix. One of the function's arguments takes a vector. I would like to apply the first element of the vector to the first row, the second element to the second row, etc. For example: set.seed(12...
more »

## c++ How to get acces of function that is in parent class?

I have class Books and child class BookClient. In class Books their is function that calculates age of book: int age() {return 2017 - getage();} I want function that prints books that are >5 age and are form certain publisher. I am using range-b...
more »