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

How to ensure the template type is scalar in D?

I have two functions: one is scalar multiplication for a vector and other - vector-matrix multiplication: pure T[] mul(S, T)(S s, T[] a) and pure T[] mul(T)(T[] a, T[][] B) Of course this leads to a conflict, as S can be a vector too, so that…
akalenuk
  • 3,815
  • 4
  • 34
  • 56
6
votes
6 answers

Vectorizing a function (Python)

I'm new to python and trying to do a HW assignment and it keeps throwing this error back at me (in iPython Notebook): "TypeError: unsupported operand type(s) for ** or pow(): 'list' and 'float'" Here's the formula i'm trying to imitate:…
user2839099
  • 61
  • 1
  • 1
  • 2
6
votes
3 answers

List of Scalar Data Types

Im looking for a list of all the scalar data types in Objective C, complete with their ranges (max/min values etc). Sorry for the simple question, Im just really struggling to find anything like this.
Jimmery
  • 9,783
  • 25
  • 83
  • 157
5
votes
2 answers

convert PDL scalar to Perl scalar

I have a function that uses PDL. The final step is a dot product so it returns a scalar. However, when I try to print this scalar, it is clearly still a piddle and prints like this on screen: [ [ 3 ] ] I'm wondering how I can convert it back to…
Zhang18
  • 4,800
  • 10
  • 50
  • 67
5
votes
3 answers

Rounding in Google Query Language

I'd like to implement a series of queries with rounding in Google Query Language, such as: select round(age,-1), count(id) group by round(age,-1) or any combination of int/floor/etc. select int(age/10)*10, count(id) group by int(age/10)*10 Is…
prototype
  • 7,249
  • 15
  • 60
  • 94
5
votes
2 answers

Scalar type in Managed Object only works for IPhone 5

Property 'Latitude' is a scalar type on class 'LatitudeLongitude'. Cannot generate a setter method for it. When I generated codes for my managed object, I got a message whether I want scalar properties for primitive data type. should I use it? I…
user4951
  • 32,206
  • 53
  • 172
  • 282
5
votes
1 answer

GraphQL Nexus Schema (nexusjs) doesn't compile with scalar types

I am trying to follow the documentation on the Nexus-Schema (nexusjs) website for adding scalar types to my GraphQL application. I have tried adding many of the different implementations to my src/types/Types.ts file using the samples provided in…
Krejko
  • 901
  • 1
  • 9
  • 23
5
votes
1 answer

How do I make a subroutine that accepts an array *or* a variable number of scalars?

I'm looking to make a subroutine mysub which should behave such that the following two calls are effectively the same. mysub(["values", "in", "a", "list"]); mysub("Passing", "scalar", "values"); What is the proper syntax to make this happen?
ajwood
  • 18,227
  • 15
  • 61
  • 104
5
votes
3 answers

Can scalar functions be applied before filtering when executing a SQL Statement?

I suppose I have always naively assumed that scalar functions in the select part of a SQL query will only get applied to the rows that meet all the criteria of the where clause. Today I was debugging some code from a vendor and had that assumption…
Peter Recore
  • 14,037
  • 4
  • 42
  • 62
5
votes
3 answers

What is the difference between the scalar and list contexts in Perl?

What is the difference between the scalar and list contexts in Perl and does this have any parallel in other languages such as Java or Javascript?
user47145
  • 1,775
  • 2
  • 13
  • 8
5
votes
2 answers

Why are isscalar, isvector and ismatrix all true for A = 1?

Matlab has the following functions to check inputs: isscalar to determine whether input is scalar isvector to determine whether input is a vector ismatrix to determine whether input is a matrix For A = 1 (or any "scalar" input) all of the…
Schorsch
  • 7,761
  • 6
  • 39
  • 65
5
votes
1 answer

C - only scalar operations?

Reading on Wikipedia: "The terms high-level and low-level are inherently relative. Some decades ago, the C language, and similar languages, was most often considered "high-level", as it supported concepts such as expression evaluation,…
quano
  • 18,812
  • 25
  • 97
  • 108
5
votes
2 answers

Why can I print this treating as a reference and treating it as a scalar?

In the following perl snippet: my $a1 = [ qw(rock pop musical) ]; my $b1 = [ qw( mystery action drama )]; my $c1 = [ qw( biography novel periodical)]; my @a2d = ( $a1, $b1, $c1 ); The @a2d is an array which contain…
Cratylus
  • 52,998
  • 69
  • 209
  • 339
5
votes
1 answer

How to handle properties on a SCALAR based Perl class?

In Perl, it's easy to bless a hashref and use it to store and read properties: package MyPackage; use strict; use warnings; sub new { bless {}, __PACKAGE__; } sub SomeProperty { my $self = shift; if (@_) { return…
Francisco Zarabozo
  • 3,676
  • 2
  • 28
  • 54
5
votes
3 answers

Using a scalar as a condition in perl

First timer...so let me know if there is anything that I have not paid attention to whilst posing a question. The question is how to use a scalar as a condition, as the code below does not work. my @parameter=('hub'); my…
noqa
  • 313
  • 2
  • 4
  • 11