Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6878291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:42:20+00:00 2026-05-27T04:42:20+00:00

I am interested in using a Listable Compiled function on lists that need not

  • 0

I am interested in using a Listable Compiled function on lists that need not be tensors. I want to understand why some functions work, where as others do not and shut down the kernel. Here is an example.

Suppose we have two matrices m1 and m2 as follows.

m1 = {{1.0, 0.5, 0.5}, {0.5, 1.0, 0.5}, {0.5, 0.5, 1.0}};

m2 = {{1.0, 0.5}, {0.5, 1.0}};

We can make two different lists, the first is a tensor and the second is not.

In[3]:= mList1 = {m1, m1};

In[4]:= TensorQ[mList1]

Out[4]= True

In[5]:= mList2 = {m1, m2};

In[6]:= TensorQ[mList2]

Out[6]= False

Similarly, let v1 and v2 be two vectors and vList1 and vList2 be two lists as follows

v1 = {1.0, 1.5, 0.9};

v2 = {1.1, 0.7};

In[9]:= vList1 = {v1, v1};

In[10]:= TensorQ[vList1]

Out[10]= True

In[11]:= vList2 = {v1, v2};

In[12]:= TensorQ[vList2]

Out[12]= False

Now we define two listable functions func1 and func2

func1 = Compile[{{m, _Real, 2}, {v, _Real, 1}},
   m.v,
   RuntimeAttributes -> Listable
   ];

func2 = Compile[{{m, _Real, 2}, {v, _Real, 1}, {r, _Real}},
   r*(m.v),
   RuntimeAttributes -> Listable
   ];

func1 works on both tensor and non tensor lists as can be seen below

In[15]:= func1[mList1, vList1]

Out[15]= {{2.2, 2.45, 2.15}, {2.2, 2.45, 2.15}}

In[16]:= func1[mList2, vList2]

Out[16]= {{2.2, 2.45, 2.15}, {1.45, 1.25}}

func2 works on the tensor lists mList1 and vList1 and an real constant as follows

In[17]:= func2[mList1, vList1, 5.0]

Out[17]= {{11., 12.25, 10.75}, {11., 12.25, 10.75}}

The function is capable of using the single real 5.0, repeatedly.

However, the same function does not work on the non-tensor lists mList2 and vList2. The following shuts down my kernel (Mathematica 8.0.4, on Windows Vista).

func2[mList2, vList2, 5.0]

Interestingly, the following works.

In[18]:= func2[mList2, vList2, {5.0, 5.0}]

Out[18]= {{11., 12.25, 10.75}, {7.25, 6.25}}

Can anybody explain this behavior?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:42:20+00:00Added an answer on May 27, 2026 at 4:42 am

    This is a bug and has been fixed in the development version. For now you have to use the {5.,5.} version.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am interested in using some kind of a command-line utility for SQL Server
I'm interested in using the WMD editor in another project * but I'm not
I’m interested in using libhid to access a custom HID device that we are
I am interested in using functors (function objects) in Java. With quick googling I
I`m interested in using some MOSS dll's if my solution is deployed on MOSS.
I'm not interested in using the handle returned from _beginthreadex() . Is it safe
I'm interested in using Subsonic 3.0 for developing a new ASP.Net MVC application that
Interested in using libxml2dom in a Python script of mine to (obviously) parse some
I am interested in using the full text search capability of SQLite. I understand
I am interested in using a free library that has features similar to MSMQ

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.