# v_qrabs

## PURPOSE

V_QRABS absolute value and normalization of a real quaternions [m,q]=[q1]

## SYNOPSIS

function [m,q]=v_qrabs(q1)

## DESCRIPTION

    V_QRABS absolute value and normalization of a real quaternions [m,q]=[q1]

     Inputs:   q1(4n,...)  A real quaternion array. Each quaternion is a column
                              vector of the form [r, i, j, k]'

     Outputs:  m(n,...)    Array of quaternion magnitudes: m=sqrt(q'*q)
               q(4n,...)   Normalized version of q1 with unit magnitude
                              a zero quaternion is normalized to [1 0 0 0]'

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

## SOURCE CODE

    0001 function [m,q]=v_qrabs(q1)
    0002 %V_QRABS absolute value and normalization of a real quaternions [m,q]=[q1]
    0003 %
    0004 % Inputs:   q1(4n,...)  A real quaternion array. Each quaternion is a column
    0005 %                          vector of the form [r, i, j, k]'
    0006 %
    0007 % Outputs:  m(n,...)    Array of quaternion magnitudes: m=sqrt(q'*q)
    0008 %           q(4n,...)   Normalized version of q1 with unit magnitude
    0009 %                          a zero quaternion is normalized to [1 0 0 0]'
    0010
    0011 %      Copyright (C) Mike Brookes 2000-2012
    0012 %      Version: $Id: v_qrabs.m 10865 2018-09-21 17:22:45Z dmb $
    0013 %
    0014 %   VOICEBOX is a MATLAB toolbox for speech processing.
    0015 %   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
    0016 %
    0017 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    0018 %   This program is free software; you can redistribute it and/or modify
    0019 %   it under the terms of the GNU Lesser General Public License as published by
    0020 %   the Free Software Foundation; either version 3 of the License, or
    0021 %   (at your option) any later version.
    0022 %
    0023 %   This program is distributed in the hope that it will be useful,
    0024 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
    0025 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    0026 %   GNU Lesser General Public License for more details.
    0027 %
    0028 %   You can obtain a copy of the GNU Lesser General Public License from
    0029 %   https://www.gnu.org/licenses/ .
    0030 %
    0031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    0032 q1=randn(8,3);
    0033 q1(9:12)=0;
    0034 s=size(q1);
    0035 q=reshape(q1,4,[]);
    0036 m=sqrt(sum(q.^2,1));
    0037 q(:,m>0)=q(:,m>0)./m(ones(4,1),m>0);
    0038 q(1,m<=0)=1;
    0039 q=reshape(q,s);
    0040 s(1)=s(1)/4;
    0041 m=reshape(m,s);