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
3
votes
1 answer

Setting uniform Numpy dtype of all scalars and arrays (how to avoid downcasting in precision)

Question: What is the simplest way to set the dtype of all scalar and array variables using numpy? Problem: As the size and complexity of my algorithms grow, I am finding it very difficult tracing convergence problems due to round-off and…
ecoe
  • 4,994
  • 7
  • 54
  • 72
3
votes
2 answers

How to multiply a numpy array by a scalar

I have a numpy array and I'm trying to multiply it by a scalar but it keeps throwing an error: TypeError: unsupported operand type(s) for *: 'numpy.ndarray' and 'int' My code is: Flux140 = ['0.958900', 'null', '0.534400'] n = Flux140*3
user2596490
  • 31
  • 1
  • 1
  • 2
3
votes
2 answers

Explaining behavior of methods & variables with same names & other properties in ruby

I am just trying to understand the behaviour of the destroy method in the following code: UPDATE : Please note my intention is to understand the behaviour, not the immediate solution for assigning nil to the variable. def conf @conf ||= {…
Mohit Chawla
  • 219
  • 2
  • 11
3
votes
2 answers

Must declare the scalar variable error in subselect SQL

I am trying to create a SQL script that will create a nice easy to update script where another person only needs to update the constants involved and then run a query, however I an getting into trouble when using declared variables in sub selects. I…
Greg Clout
  • 166
  • 2
  • 9
3
votes
3 answers

How to compare scalars in OpenCV

I have a class called "myClass", which returns "cv::Scalar" type, and I want to do this: cv::Scalar myValue; for ( myValue > myClass (i,j) ) .... But the comparison part in the "for" line gives out error, saying "no operator > matches these…
E_learner
  • 3,512
  • 14
  • 57
  • 88
3
votes
2 answers

Why does my function returns a comma separated list instead of rows (SQL Server)?

I have a function that usually returns one value. However, when there are multiple rows that it could return, it returns a comma-delimited string of all of the values. I'm new to using functions, so I'm wondering how it does this? Is it looping…
eek
  • 688
  • 2
  • 21
  • 32
2
votes
3 answers

How can I tie lists, scalars and vectors together in this Python assignment?

Before I begin- let it be known that my class IS allowed to seek outside help for this assignment, provided we do not copy code directly. What I am asking for is help, not blatantly dishonestly obtained code. I am not intending to cheat by asking…
2
votes
3 answers

Scalar function in LinqToSql

In ADO.Net/SQLClient I would often do something like this: SELECT COUNT(*) FROM SomeTable WHERE SomeKey = 1234 ...and fire it using executescalar to return the value of count - for a simple check if something exists. How would I do the same using…
Kjensen
  • 12,447
  • 36
  • 109
  • 171
2
votes
3 answers

Scalar function taking so much time

I need someone who can tell me what I'm missing. I have this scalar function in SQL Server 2008: ALTER function [dbo].[SKU](@id1 int, @id2 int) returns int begin return ( SELECT SUM(Value) FROM Table where id_1 = @id1 and id_2 = @id2) end And…
Esselans
  • 1,540
  • 2
  • 24
  • 44
2
votes
2 answers

Perl structures and assignment

In perldata, I found the following examples and explanations. @foo = ('cc', '-E', $bar); assigns the entire list value to array @foo, but $foo = ('cc', '-E', $bar); assigns the value of variable $bar to the scalar variable $foo. This really…
user1109094
  • 93
  • 2
  • 7
2
votes
5 answers

How to take a value from a database? Must declare the scalar variable "@ID1"

public partial class Form3 : Form { string var; int ID1; private void button1_Click(object sender, EventArgs e) { ID1 = int.Parse(textBox1.Text); SqlConnection cn = new SqlConnection(@"Data…
user1075569
  • 41
  • 1
  • 4
2
votes
1 answer

Can't generate scalar JSON in gqlgen

I have a GQL scheme: extend type MyType @key(fields: "id") { id: ID! @external properties: JSON @external myField: String! @requires(fields: "properties") } scalar JSON In graph/model/model.go: package model import ( "encoding/json" …
user8439944
  • 73
  • 1
  • 7
2
votes
1 answer

Perl: How is to be interpreted a negation of an array and scalar?

What happens if I do a negation of an array or a scalar? Using the script below I got these results: $x = 0 ------------- $x: 0 !$x: 1 $x = 1 ------------- $x: 1 !$x: @x = () ------------- @x: !@x: 1 @x = qw ( a b ) ------------- @x: …
giordano
  • 2,954
  • 7
  • 35
  • 57
2
votes
2 answers

Assigning array to an int in C

I have written the following code in C int main(){ int a = {1, 2, 3}; } It seems like the variable assigned, in this case a, always takes the value of the first array element. Now I'm wondering if the other array elements are discarded, or…
Daniel D.
  • 178
  • 2
  • 15
2
votes
2 answers

In Perl, how to create a "mixed-encoding" string (or a raw sequence of bytes) in a scalar?

In a Perl script of mine, I have to write a mix of UTf-8 and raw bytes into files. I have a big string in which everything is encoded as UTF-8. In that "source" string, UTF-8 characters are just like they should be (that is, UTF-8-valid byte…
Kzwix
  • 161
  • 7