Skip to content
DeepForgeby svx
All problems
EasyLinear Algebrala-022

2D Scaling Matrix

Problem

Build the 2x2 scaling matrix with horizontal factor sx and vertical factor sy:

S = [[sx, 0], [0, sy]]

Hint

The off-diagonal entries are always 0.

Test cases

case 1
in: [2,3]
expected: [[2,0],[0,3]]
case 2
in: [1,1]
expected: [[1,0],[0,1]]
case 3
in: [-1,2]
expected: [[-1,0],[0,2]]
case 4
in: [0.5,-1.5]
expected: [[0.5,0],[0,-1.5]]
Starter codePython
def scaling_matrix(sx, sy):
    # Your code here
    pass

4 test cases · run your code against them in the editor