Questions tagged [operation]

734 questions
6
votes
1 answer

How to operate elementwise on a matrix of type scipy.sparse.csr_matrix?

In numpy if you want to calculate the sinus of each entry of a matrix (elementise) then a = numpy.arange(0,27,3).reshape(3,3) numpy.sin(a) will get the job done! If you want the power let's say to 2 of each entry a**2 will do it. But if you have a…
Aufwind
  • 25,310
  • 38
  • 109
  • 154
6
votes
2 answers

Why does C# attempt to convert int? to byte when using Math.Min?

I just discovered this interesting issue: int done = 50; int? total = 100; var perc = done * 100 / total; // No problem // Error: Argument 2: cannot convert from 'int?' to 'byte' // Argument 1 is still int32 var perc2 = Math.Min(100, done * 100 /…
Luke Vo
  • 17,859
  • 21
  • 105
  • 181
6
votes
3 answers

Why would someone use set.remove() instead of set.discard()

I'm currently learning Python and I am just wondering in what situation one would use .remove() rather than .discard() when removing values from a set. Since .discard() does not raise an error when removing a element form a set if the element isn't…
TechSupportz
  • 75
  • 2
  • 5
5
votes
4 answers

C bit operation puzzle

/* * ezThreeFourths - multiplies by 3/4 rounding toward 0, * Should exactly duplicate effect of C expression (x*3/4), * including overflow behavior. * Examples: ezThreeFourths(11) = 8 * ezThreeFourths(-9) = -6 * …
user1114371
  • 89
  • 1
  • 7
5
votes
5 answers

What is the most efficient way to compute a Kronecker Product in TensorFlow?

I am interested in implementing this paper on Kronecker Recurrent Units in TensorFlow. This involves the computation of a Kronecker Product. TensorFlow does not have an operation for Kronecker Products. I am looking for an efficient and robust way…
jasekp
  • 990
  • 1
  • 8
  • 17
5
votes
5 answers

Mathematical operation to keep number not less than zero

In programming, modulus is useful to keep numbers in range not exceeding an upper bound limit. For example: int value = 0; for (int x=0; x<100; x++) cout << value++%8 << " "; //Keeps number in range 0-7 Output: 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7…
user3437460
  • 17,253
  • 15
  • 58
  • 106
5
votes
1 answer

soapaction in WSDL using CXF

I am developing webservice using CXF. I use HTTP binding so according to http://www.w3.org/TR/wsdl#_soap:operation soapaction is mandatory for this type of transport. The problem is that I want to deploy the same application for test and production…
Aleksander Gralak
  • 1,509
  • 10
  • 26
4
votes
1 answer

./sysroot.sh: Operation not permitted

im trying to install the cydia source code. $ git clone git://git.saurik.com/cydia.git $ cd cydia but when i typing "./sysroot.sh" i got this error: -bash: ./sysroot.sh: /usr/bin/env: bad interpreter: Operation not permitted what the problem?
theShay
  • 247
  • 5
  • 20
4
votes
3 answers

How provide in java atomic read/write of 2 variables together?

In my class I have code like: int counter1; int counter2; public void method1(){ if (counter1>0) { ...........do something if (counter2>0) { ....do something else } } public void method2() { counter1=0; counter2=0; } I need that…
user710818
  • 23,228
  • 58
  • 149
  • 207
4
votes
2 answers

Ruby - Timestamp of yesterday to a certain time

I have the following issue: I want to get the timestamp of yesterday on a specific time. With what I've come up so far is: Time.local(Time.now.strftime("%Y"), Time.now.strftime("%m"), (Time.now.strftime("%d")-1), 23, 59, 59).tv_sec I'm new to Ruby…
TehQuila
  • 628
  • 1
  • 8
  • 19
4
votes
5 answers

Why can't we use a void* to operate on the object it addresses

I am learning C++ using C++ Primer 5th edition. In particular, i read about void*. There it is written that: We cannot use a void* to operate on the object it addresses—we don’t know that object’s type, and the type determines what operations we…
Jason
  • 36,170
  • 5
  • 26
  • 60
4
votes
3 answers

Find max and min value on a dataframe, ignoring NAs

I need to find the max and min value in a dataframe "df" like this: col1 col2 col3 7 4 5 2 NA 6 3 2 4 NA NA 1 The result should be: min = 1 and max = 7. I have used this function: min <- min(df, na.rm=TRUE) max…
EmaK
  • 154
  • 1
  • 9
4
votes
1 answer

java widening final variable

I'm reading java OCA certification documentation. Some primitive operations behavior seems realy strange for me. it is said that all byte, short and char value are automatically widening to int when used as operand for arithmetic operations.…
soung
  • 1,411
  • 16
  • 33
4
votes
1 answer

Source code of Haskell's built-in operations

This question is related to this overflow post. The chosen answer there tells us that we can look up the source codes for built in functions on hackage site, for example curry. What I'd like to ask for, however, is the location of the source codes…
Student
  • 400
  • 3
  • 10
4
votes
8 answers

How do I perform multiple operations in a list comprehension

L = [random.randint(0,50) for i in range(5) random.randint(0,12) for i in range(2)] How do I get it to pick 5 random numbers between (0,50), then 2 random numbers between(0,12)?
Lewis
  • 139
  • 1
  • 7
1 2
3
48 49