Questions tagged [scalar]

In computing and programming, a scalar variable or value refers to a single value, as opposed to data structures such as arrays or lists.

In computing and programming, a scalar variable refers to a single value, as opposed to data structures such as or s. A scalar can be of any type, including a complex type such as an object or string. Being scalar only means that it is manipulated as a single value.

As an example, the string type in C++ is considered to be a scalar as it is a primitive type containing a single value, although in the C language there is no such primitive type. Thus, the char array implementation of strings typically used would not be considered as a scalar.

See also:

532 questions
2
votes
2 answers

Perl @$ syntax meaning

I have adapted a code fragment for getting column names in DBI and it works fine: $tableColumns = $databaseStatement->{NAME}; print $fileHandle $documentFormatter->{openTableRow}; foreach(@$tableColumns){ print $fileHandle…
2
votes
2 answers

How can one initialize data for a contour plot using a function that takes one input and outputs a scalar value?

NOTE: The post looks longer than it ought to because of docstrings and an array consisting of 40 datetimes. I have some time-series data. For examples sake, let's say I have three parameters, each consisting of 40 data points: datetimes (given by…
user7345804
2
votes
2 answers

Can't write Tensorflow scalar summary to event log

i'm trying to learn how to write tensorflow code on my own, but i'm stuck with this very basic issue: During learning steps i can't write any scalar summary to the event file, which is needed for Tensorboard. Here is my code: import tensorflow as…
ptamas90
  • 147
  • 3
  • 9
2
votes
1 answer

How to input scalar (non-image) values to CNNs?

The classification task is based on a image and a scalar value. If I encoded the scalar value as image pixels with that value (or a normalized version of the same) and append it as another layer in the input image, I would be wasting convolutional…
Saravanabalagi Ramachandran
  • 8,551
  • 11
  • 53
  • 102
2
votes
1 answer

Difference in scalar product with matlab and python

I have a problem. I have two arrays with the size of 82248x20 and if i do the following in Matlab A=X'*Y it will give me 6.152847328855238e-18 for the second value. If i do it in Python with anything…
2
votes
1 answer

How does the "Array dereferencing" work on a scalar value of type boolean/integer/float/string as of PHP version 7.2.0?

I am using PHP 7.2. I come across the following note from the arrays chapter of PHP Manual Array dereferencing a scalar value which is not a string silently yields NULL, i.e. without issuing an error message. I understand how to dereference an…
user9059272
2
votes
2 answers

Using conditional statement to subtract scalar from pandas df column gives ValueError: The truth value of a Series is ambiguous

I'm trying to execute: if df_trades.loc[:, 'CASH'] != 0: df_trades.loc[:, 'CASH'] -= commission and then I get the error. df_trades.loc[:, 'CASH'] is a column of floats. I want to subtract the scalar commission from each entry in that column. For…
user2398046
2
votes
1 answer

GLSL sum of vector vec3 and float

This may be odd because as I understand a vector and a scalar cannot be added. However I've found this sample and in line 157 it doing the following operation: hsv.x + vec3(0.,2./3.,1./3.) where hsv.x happens to be a float number, the value comes…
Pipo
  • 41
  • 1
  • 7
2
votes
2 answers

Topicalising a variable using "for" is apparently bad. Why?

So I answered a question on SO and got a lot of flack for it. I have been using Perl for many years and use this topicalising quite a lot. So let's start with some code. I am doing search and replace in these examples. The idea is to search for one…
Gerhard
  • 22,678
  • 7
  • 27
  • 43
2
votes
1 answer

Multiplying by a one element matrix

I want to multiply a 1x1 matrix by an 8x8 matrix. Obviously I know that you cannot multiply matrices of these two shapes. My question is how to I "extract" the value from the 1x1 matrix so that it's equivalent to multiplying the 8x8 matrix by a…
Katey
  • 85
  • 1
  • 2
  • 9
2
votes
1 answer

Non-element-wise vector division in Matlab returns a scalar! What is it?

I spent over an hour chasing a bug in my code which was leading to a precision error. It turned out that in one of my equations, I had forgotten to divide two vectors element-wise; I had written / instead of ./. Usually Matlab gives an error in…
MGA
  • 1,658
  • 15
  • 28
2
votes
0 answers

track specific color in a video with opencv (Java)

Hello :) I'm using openCV library in java. I have a video of a mouse running on wheel. On the wheel, I have put a marker. I need to know how many loops does the mouse run on it. So to do this, I need to track the marker on the wheel. I wrote the…
Tal Ohana
  • 21
  • 3
2
votes
1 answer

Must declare the scalar variable '@connection' error

Below is the code for which am getting must declare scalar variable @connection error. I don't know where I am going wrong. Please guide protected void LinkButton1_Click(object sender, EventArgs e) { string connection =…
user3660473
  • 131
  • 2
  • 3
  • 15
2
votes
2 answers

NASM - Extending label with bit flag

I need to set the highest bit of some label address/offset. I tried: test.nasm: BITS 32 dw mylabel | 0x8000 mylabel: dd 0 But when trying to assemble this I get: nasm -f bin test.nasm test.nasm:3: error: `|' operator may only be applied to scalar…
masterxilo
  • 2,503
  • 1
  • 30
  • 35
2
votes
0 answers

Keep as numpy array type when returning a scalar

An array a = np.array(1) is convenient as it allows a.shape ** How can I preserved the numpy class type when doing an operation that returns a scalar e.g. b = 0. c = np.dot(a.T,…
Alexander McFarlane
  • 10,643
  • 9
  • 59
  • 100