MATLAB exercise program (third-order tensor T-QR decomposition)

Source: Internet
Author: User

Here, the so-called tensor is different from the tensor In the column. The tensor is more physically used, and this tensor is the extension of the matrix. For example, a zero-order tensor is a number, a first-order tensor is a vector, a second-order tensor is a matrix, and a third-order tensor is a set of higher-dimensional numbers. This field is still very new in mathematics. We all know how to calculate the rank of the matrix, but the rank of the three-dimensional tensor or Higher Dimensional Tensor has no mathematical result. As for the Singular Value Decomposition of tensor, it is only very early to use hosvd for processing. I don't think this is completely appropriate. The new decomposition algorithm is not even developed by laomei, from two-dimensional to multi-dimensional, there are indeed many basic theories that are not applicable. Although there are basic algorithms like two tensor multiplication, I feel that they are not common and need to be improved.

The following is the method of multiplication and decomposition of tensor in my paper. Her theory may be incorrect, but in this new field, everyone is exploring.

The paper is here: Workshop. From the MATLAB Point of View of T-SVD and T-QR code is actually very similar.

Main. m

clear all;close all;clc;n1=3;n2=3;n3=3;A(:,:,1)=[10 23 34;43 55 63;72 85 96];A(:,:,2)=[24 17 35;52 36 55;81 94 75];A(:,:,3)=[65 16 52;21 47 78;92 33 43];%A=imread('s.jpg');D=fft(A,[],3);for i=1:n3    [q r]=qr(D(:,:,i));    %[u s v]=svd(D(:,:,i));    Q(:,:,i)=q;    R(:,:,i)=r;    %S(:,:,i)=s;endQ=ifft(Q,[],3);R=ifft(R,[],3);%S=ifft(S,[],3);B(:,:,1)=eye(n1,n2);B(:,:,2)=zeros(n1,n2);B(:,:,3)=zeros(n1,n2);%c=mul(mul(U,S),transpos(V));c=mul(Q,R);

Mul. m tensor multiplication, the formula of 3.3 on page 7

function c=mul(a,b)    [a_n1 a_n2 a_n3]=size(a);    [b_n1 b_n2 b_n3]=size(b);    c=zeros(a_n1,b_n2,a_n3);    A=cell(a_n3,1);    B=cell(b_n3,1);        for i=1:a_n3        A{i}=a(:,:,i);        B{i}=b(:,:,i);    end    index_up=zeros(1,a_n3);    index_down=zeros(1,a_n3);    for i=1:a_n3            index_up(i)=a_n3-i+1;        index_down(i)=i;    end        s=cell(a_n3,a_n3);    for i=1:a_n3        for j=1:a_n3            if i==j                s{i,j}=A{1};            end                   if j>i                s{i,j}=A{index_up(j-i)};            end                   if j<i                s{i,j}=A{index_down(i-j+1)};            end              end       end        re=cell(a_n3,1);    for i=1:a_n3        re{i}=zeros(a_n1,b_n2);    end    for i=1:a_n3        for j=1:a_n3            for k=1:1                re{i,k}=re{i,k}+s{i,j}*B{j,k};            end        end        end    for i=1:a_n3        c(:,:,i)=re{i};            end    end

Transpos. m tensor transpose. The formula of example3.15 on page 10 of this paper

function a=transpos(b)        [n1 n2 n3]=size(b);    a=zeros(n2,n1,n3);    for i=1:n3        a(:,:,i)=b(:,:,i)';    endend

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.