[Question]
  [
In this challenge, you will be given a square matrix `A`, a vector `v`, and a scalar `λ`. You will be required to determine if `(λ, v)` is an eigenpair corresponding to `A`; that is, whether or not `Av = λv`.
# Dot Product
The dot product of two vectors is the sum of element-wise multiplication. For example, the dot product of the following two vectors is:
```
(1, 2, 3) * (4, 5, 6) = 1*4 + 2*5 + 3*6 = 32
```
Note that the dot product is only defined between two vectors of the same length.
# Matrix-Vector Multiplication
A matrix is a 2D grid of values. An `m` x `n` matrix has `m` rows and `n` columns. We can imagine an `m` x `n` matrix as `m` vectors of length `n` (if we take the rows).
Matrix-Vector multiplication is defined between an `m` x `n` matrix and a size-`n` vector. If we multiply an `m` x `n` matrix and a size-`n` vector, we obtain a size-`m` vector. The `i`-th value in the result vector is the dot product of the `i`-th row of the matrix and the original vector.
### Example
```
        1 2 3 4 5
Let A = 3 4 5 6 7
        5 6 7 8 9
        1
        3
Let v = 5
        7
        9
```
If we multiply the matrix and the vector `Av = x`, we get the following:
x1 = AT1 \* v `/* AT1 means the first row of A; A1 would be the first column */` = (1,2,3,4,5) \* (1,3,5,7,9) = 1\*1 + 2\*3 + 3\*5 + 4\*7 + 5\*9 = 1+6+15+28+45 = 95
x2 = AT2 \* v = (3,4,5,6,7) \* (1,3,5,7,9) = 3\*1 + 4\*3 + 5\*5 + 6\*7 + 7\*9 = 3+12+25+42+63 = 145
x3 = AT3 \* v = (5,6,7,8,9) \* (1,3,5,7,9) = 5\*1 + 6\*3 + 7\*5 + 8\*7 + 9\*9 = 5+18+35+56+81 = 195
So, we get `Av = x = (95, 145, 195)`.
# Scalar Multiplication
Multiplication of a scalar (a single number) and a vector is simply element-wise multiplication. For example, `3 * (1, 2, 3) = (3, 6, 9)`. It's fairly straightforward.
# Eigenvalues and Eigenvectors
Given the matrix `A`, we say that `λ` is an eigenvalue corresponding to `v` and `v` is an eigenvector corresponding to `λ` **if and only if** `Av = λv`. (Where `Av` is matrix-vector multiplication and `λv` is scalar multiplication).
`(λ, v)` is an eigenpair.
# Challenge Specifications
### Input
Input will consist of a matrix, a vector, and a scalar. These can be taken in any order in any reasonable format.
### Output
Output will be a truthy/falsy value; truthy if and only if the scalar and the vector are an eigenpair with the matrix specified.
# Rules
* Standard loopholes apply
* If a built-in for verifying an eigenpair exists in your language, you may not use it.
* You may assume that all numbers are integers
# Test Cases
```
 MATRIX  VECTOR  EIGENVALUE
 2 -3 -1    3
 1 -2 -1    1    1    ->    TRUE
 1 -3  0    0
 2 -3 -1    1
 1 -2 -1    1    -2   ->    TRUE
 1 -3  0    1
 1  6  3    1
 0 -2  0    0    4    ->    TRUE
 3  6  1    1
 1  0 -1    2
-1  1  1    1    7    ->    FALSE
 1  0  0    0
-4 3    1    
 2 1    2    2    ->    TRUE
2    1    2    ->    TRUE
```
I will add a 4x4 later.
[Unreadable Test Cases that are easier for testing](https://hastebin.com/niqinazizu.lua)
  
[Answer]
## Mathematica, 10 bytes
```
#2.#==#3#&
```
Takes input like `{vector, matrix, scalar}` and returns a boolean.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 5 bytes
```
æ.⁵⁼×
```
This is a triadic, full program.
[Try it online!](https://tio.run/nexus/jelly#@394md6jxq2PGvccnv7///9oQx0FEIr9r2v0PzpawUhHQdcYiA1jdbgUokFSukaoXKCsgkFsLAA "Jelly – TIO Nexus")
### How it works
```
æ.⁵⁼×  Main link
       Left argument:  v (eigenvector)
       Right argument: λ (eigenvalue)
       Third argument: A (matrix)
  ⁵    Third; yield A.
æ.     Take the dot product of v and A, yielding Av.
    ×  Multiply v and λ component by component, yielding λv.
   ⁼   Test the results to the left and to the right for equality.
```
[Answer]
# MATL, 7 bytes
```
*i2GY*=
```
Inputs in order: `l`,`v`,`A`.
Explanation:
```
*  % implicitly get l and v, multiply.
i  % get A
2G % get second input, i.e., v again
Y* % perform matrix multiplication
=  % test equality of both multiplications
```
Surprisingly long answer, if you ask me, mostly because I needed a way to get all the input correctly. I do not think that less than 5 bytes is possible, but it would be cool if someone found a 5 or 6 byte solution.
Basically, this calculates `l*v==A*v`.
[Answer]
# [CJam](https://sourceforge.net/p/cjam), 15 bytes
```
q~W$f.*::+@@f*=
```
Takes input in the form `vector scalar matrix`.
[Try it online!](https://tio.run/nexus/cjam#@19YF66SpqdlZaXt4JCmZfv/f7ShAhDGKugaKURHGynoGivoGsYCBYF8KMNYQcEgNhYA "CJam – TIO Nexus")
**Explanation**
```
q~               e# Read and eval the input
  W$             e# Copy the bottom most value (the vector)
    f.*::+       e# Perform element-wise multiplication with each row of the matrix, then
                 e#   sum the results of each (ie dot product with each row) 
          @@     e# Move the resulting vector to the bottom of the stack
            f*   e# Element-wise multiplication of the scalar and the vector
              =  e# Check if the two vectors are equal
```
[Answer]
# MATLAB, 16 bytes
```
@(A,v,l)A*v==v*l
```
Rather trivial answer. Defines an anonymous function taking the inputs, and calculates element-wise equality of the resulting vectors. A single zero in a logical array makes an array falsey in MATLAB.
[Answer]
# MATLAB, 38 bytes
```
function r=f(m,v,s);r=isequal(m*v,s*v)
```
Returns 1 or 0.
# MATLAB, 30 bytes
```
function r=f(m,v,s);r=m*v==s*v
```
Returns
```
1
1
1
```
as a truthy value. A falsy value is a similar vector with any or all values 0 instead of 1.
[Answer]
# C++, ~~225~~ 203 bytes
*Thanks to @Cort Ammon and @Julian Wolf for saving 22 bytes!*
```
#import<vector>
#define F(v,i)for(i=0;i<v.size();++i)
using V=std::vector<float>;int f(std::vector<V>m,V v,float s){V p;int i,j;F(m,i){p.push_back(0);F(v,j)p[i]+=v[j]*m[i][j];}F(v,i)v[i]*=s;return v==p;}
```
[Try it online!](https://tio.run/nexus/cpp-gcc#jY/BbsIwDIbvfYoILgkE1Ba0SaTtkUfohaGpK@kWRtOqSXNY1GdnTlo2bhDJsuP8/vznOhd123Q6MbzUTZcF8xOvhORojw0VpGo6LNKQicSslfjhmLDlUpCgV0J@ojxV@rTbjaNJdWkKnTEhNarw/UOe1TRHhnoBUsTmqPUyQc9sj2vYY9t126uv94@i/MYhYW77mbQHcVym5nA@LmooIbNh9GXgukgV67juO4lMmrZsuM6FLC/9iaNENEp3vKizwO2pCyExCWyA4HhnZdNrlCRg1NqYotUGIhqojSDHdzX0w2GgyEIRuRoScYOzNznzuP/zHG7iRZ4HfRA8AIIOvUBsABKOQGfEWfL96AYMR@D2CV44mVq5i4/RoXuYHMZ/P359AFxtJ3du5GYmhvzoZ/Eo9koWDNdf)
[Answer]
# Julia, 17 bytes
```
(a,b,c)->a*b==b*c
```
[Try it online!](https://tio.run/nexus/julia5#S7P9r5Gok6STrKlrl6iVZGubpJX8v6AoM69EI00j2khB11hB19BawVBB1wjGMFYwiNWJNgayrUEsQ03N/wA "Julia 0.5 – TIO Nexus")
[Answer]
# Python 2.7, 33 bytes
```
f=lambda m,s,e:all(m.dot(s)==e*s)
```
input: m=matrix, s=scalar, e=eigenvalue. M and s are numpy arrays
[Answer]
# [Python 3](https://docs.python.org/3/), ~~96~~ 70 bytes
No builtins for matrix-vector or scalar-vector multiplication!
```
lambda A,L,v:all(L*y==sum(i*j for i,j in zip(x,v))for x,y in zip(A,v))
```
[Try it online!](https://tio.run/nexus/python3#jZC9DoIwFEZneIo7FvM1ocVoQsLgzhs0DKiQ1CAaQQO@PN6Wn9mJ5uTklH5TnTXl/Xwt6YQcn7RsGpHvxizr3ndhdzeqHy@yuJFt6WufYsAnihwbMK7s5NjUV11/Kbuqo4xMGAhjNGQCqQoYBam3U4K4KEAmgeITSEX4R1esMyKpF1/hgISd2Nkc4uCBjdmNvbvf1HjuyaXiydzVy28cF1fufVVvKc2f9U49M0/CInRDuOcjj9wY2wRpGDxftu1FLfysPM8P "Python 3 – TIO Nexus")
-26 bytes by using `zip` thanks to @LeakyNun!
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 11 bytes
```
vy²*O})²³*Q
```
[Try it online!](https://tio.run/nexus/05ab1e#@19WeWiTln@t5qFNhzZrBf7/Hx1tpKNrrKNrGKsTbaijawRnGesYxMZyRRvrGAIZXIYA "05AB1E – TIO Nexus")
```
vy²*O})     # Vectorized product-sum.
       ²³*  # Vector * scalar.
          Q # Equivalence.
```
[Answer]
# R, ~~30~~ 25 bytes
```
s=pryr::f(all(a%*%v==λ*v))
```
Anonymous function, fairly straightforward. Returns `TRUE` or `FALSE`.
[Answer]
# oK, 12 bytes
```
{y~z%+/y*+x}
```
This is a function, it takes in `[matrix;vector;scalar]`.
This does not work in k for the same reasons that `3.0~3` gives `0` as a result.
---
The following works in **k**, with **14 bytes**:
```
{(y*z)~+/y*+x}
```
[Answer]
# Axiom, 27 bytes
```
f(a,b,c)==(a*b=c*b)@Boolean
```
exercises
```
(17) -> m:=matrix[[2,-3,-1],[1,-2,-1],[1,-3,0] ]; v:=matrix[[3],[1],[0]];
(18) -> f(m,v,1)
   (18)  true
(19) -> m:=matrix[[2,-3,-1],[1,-2,-1],[1,-3,0] ]; v:=matrix[[1],[1],[1]];
(20) -> f(m,v,-2)
   (20)  true
(21) -> m:=matrix[[1,6,3],[0,-2,0],[3,6,1] ]; v:=matrix[[1],[0],[1]];
(22) -> f(m,v,4)
   (22)  true
(23) -> m:=matrix[[1,0,-1],[-1,1,1],[1,0,0] ]; v:=matrix[[2],[1],[0]];
(24) -> f(m,v,7)
   (24)  false
(25) -> m:=matrix[[-4,3],[2,1] ]; v:=matrix[[1],[2]];
(26) -> f(m,v,2)
   (26)  true
(27) -> f(2,1,2)
   (27)  true
```
[Answer]
# Python, 26 bytes
```
lambda a,b,c:c*b==a.dot(b)
```
`a` and `b` are numpy arrays, `c` is an integer.
[Try it online!](https://tio.run/nexus/python2#jZBBCoMwEEXXeopZJmUiSRQLgiexLhKtIDQq0S48vR1jbbvs7s/8x2OY3k2jX2B4ummNOyjhtj2Ms60BgxabornYsjRJOy7M8q0bPTCHM9459AOwOIpYVWkUKQpVY6VQ6E9KUdaUUlQUUHH8h1ZE00boE1eYY0qF3GEZfDkRAZU7mn1JedjEWxI2waqPG64nKrLg1KdI16h5HPGC6sn3wwIdCy9JjPdmZY7j7zhzesD2Ag "Python 2 – TIO Nexus")
[Answer]
## Clojure, 60 bytes
```
#(=(set(map(fn[a v](apply -(* v %3)(map * a %2)))% %2))#{0})
```
This checks that all deltas are zero, thus collapsing into the set of zero. Calling example:
```
(def f #(=(set(map(fn[a v](apply -(* v %3)(map * a %2)))% %2))#{0}))
(f [[1 6 3][0 -2 0][3 6 1]] [1 0 1] 4)
```
]