vecnormr

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Analytical Geometry
Introduced first in SolidGeometry 4.5, Creation date: 2019-02-07, Last change: 2025-09-14

returns for a vector list (rows) the vectnorm result

Description

Since 2017b there is a vecnorm function, unfortunatley for column format
This function is almost the same speed as than vecnorm(VL,2,2) for small VL.


See Also:

Example Illustration

 missing image of vecnormr(VL)

Syntax

LL=vecnormr(VL)

Input Parameter

VL: vector [n x 2] or [n x 3] as rows

Output Parameter

LL: vector norm of the rows

Examples


v=rand(20,3), vecnormr(v), vecnorm(v')', vecnorm(v,2,2)

v=rand(10,2), vecnormr(v)
tic; a=vecnormr(rand(1e7,3)); toc
tic; a=vecnorm(rand(1e7,3),2,2); toc




Copyright 2019-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

This function, vecnormr, is designed to compute the vector norm of each row in a matrix, where each row represents a vector. It is particularly useful for matrices where vectors are stored as rows, as opposed to the default column format used by MATLAB's built-in vecnorm function.

Input Parameters

Output Results

Algorithm Steps

  1. The function first checks if the input matrix VL has more than one row using size(VL,1) > 1.
  2. If VL has more than one row, it computes the norm of each row using vecnorm(VL,2,2). This calculates the Euclidean norm (2-norm) for each row vector.
  3. If VL has only one row, it computes the norm using vecnorm(VL), which defaults to the 2-norm.
  4. The result, LL, is a column vector where each element corresponds to the norm of a row vector from VL.

Example Usage

Here are some examples demonstrating how to use the vecnormr function:

Algorithm explaination created using ChatGPT on 2025-08-18 23:24. (Please note: No guarantee for the correctness of this explanation)

Last html export of this page out of FM database by TL: 2025-09-21