Questions tagged [operation]

734 questions
51
votes
6 answers

Multiply vector elements by a scalar value using STL

Hi I want to (multiply,add,etc) vector by scalar value for example myv1 * 3 , I know I can do a function with a forloop , but is there a way of doing this using STL function? Something like the {Algorithm.h :: transform function }?
Ismail Marmoush
  • 13,140
  • 25
  • 80
  • 114
42
votes
3 answers

PostgreSQL - IN vs ANY

I have tried both: smthng = ANY (select id from exmplTable) smthng IN (select id from exmplTable) and I am getting the same results for my data. Is there any difference for the two expressions?
PROvlima
  • 541
  • 1
  • 4
  • 9
37
votes
2 answers

Why do these two multiplication operations give different results?

Why do I need to add an "L" letter to get the correct long value? And what is the other value? long oneYearWithL = 1000*60*60*24*365L; long oneYearWithoutL = 1000*60*60*24*365; System.out.println(oneYearWithL);//gives correct calculation result :…
fareed
  • 3,034
  • 6
  • 37
  • 65
25
votes
3 answers

byte operations (XOR) in python

#!/usr/bin/env python3 import binascii var=binascii.a2b_qp("hello") key=binascii.a2b_qp("supersecretkey")[:len(var)] print(binascii.b2a_qp(var)) print(binascii.b2a_qp(key)) # here I want to do an XOR operation on the bytes in var and key and…
Jcov
  • 2,122
  • 2
  • 21
  • 32
20
votes
6 answers

Is addition of byte converts to int because of java language rules or because of jvm?

byte a = 1; byte b = 1; byte c = a + b; Throws error: possible loss of precision byte subt = a_s - a_b; ^ required: byte found: int Is this behavior has something to do with jvm or its been defined in java language . EDIT :…
Prateek
  • 12,014
  • 12
  • 60
  • 81
19
votes
5 answers

Cassandra CQLSH OperationTimedOut error=Client request timeout. See Session.execute[_async](timeout)

I want to transfer data from one Cassandra cluster (reached via 192.168.0.200) to another Cassandra cluster (reached via 127.0.0.1). The data is 523 rows but each row is about 1 MB. I am using the COPY FROM and COPY TO command. I get the following…
Rishabh Poddar
  • 919
  • 3
  • 9
  • 17
19
votes
4 answers

Illegal operation attempted on a registry key that has been marked for deletion - only in IE

I have a web application that throws the following error when running in IE: Illegal operation attempted on a registry key that has been marked for deletion It works fine in Chrome. Unfortunately this is a production deployment and I do not have…
mclaassen
  • 5,018
  • 4
  • 30
  • 52
19
votes
10 answers

Converting KB to MB, GB, TB dynamically

public String size(int size){ String hrSize = ""; int k = size; double m = size/1024; double g = size/1048576; double t = size/1073741824; DecimalFormat dec = new DecimalFormat("0.00"); if (k>0) { hrSize =…
pedja
  • 3,285
  • 5
  • 36
  • 48
18
votes
3 answers

A loopless 3D matrix multiplication in python

I am looking to do the following operation in python (numpy). Matrix A is M x N x R Matrix B is N x 1 x R Matrix multiply AB = C, where C is a M x 1 x R matrix. Essentially each M x N layer of A (R of them) is matrix multiplied independently by…
Jason
  • 181
  • 1
  • 1
  • 3
18
votes
5 answers

How do i get the invoked operation name within a WCF Message Inspector

I'm doing a message inspector in WCF: public class LogMessageInspector : IDispatchMessageInspector, IClientMessageInspector which implements the method: public object AfterReceiveRequest(ref Message request, IClientChannel channel,…
user297332
15
votes
6 answers

Python: One-liner to perform an operation upon elements in a 2d array (list of lists)?

I have a list of lists, each containing a different number of strings. I'd like to (efficiently) convert these all to ints, but am feeling kind of dense, since I can't get it to work out for the life of me. I've been trying: newVals = [int(x)…
aped
  • 193
  • 1
  • 1
  • 8
15
votes
4 answers

How to correctly use .NET2.0 serial port .BaseStream for async operation

I am attempting to use the .BaseStream property of the .NET2.0 SerialPort to do asynchronous reads and writes (BeginWrite/EndWrite, BeginRead/EndRead). I am having some success in this, but after a time, I notice (using Process Explorer) a very…
Andy
  • 5,188
  • 10
  • 42
  • 59
13
votes
1 answer

Equalizer not always supported, even when api >= 9?

before enabling equalizer capabilities, I check for api level to make sure it's equal or greater than 9. From the reports I'm getting from my users, it seems that some exceptions are thrown anyway : the code eq = new Equalizer(0,…
elgui
  • 3,303
  • 4
  • 28
  • 37
12
votes
2 answers

SWIFT - What's the difference between OperationQueue.main.addOperation and DispatchQueue.main.async?

Sometimes I must do something on the main thread and its suggested to place the code inside a OperationQueue.main.addOperation. Other times, its suggested to write the code inside DispatchQueue.main.async. What the difference between these…
12
votes
2 answers

How to multiply float with integers in C?

When I execute this code it returns me 1610612736 void main(){ float a=3.3f; int b=2; printf("%d",a*b); } Why and how to fix this ? edit : It's not even a matter of integer and float, if i replace int b=2: by float b=2.0f it return the same silly…
Wicelo
  • 2,358
  • 2
  • 28
  • 44
1
2 3
48 49